A team projects to create a clone of AirBnB.
A console is a command interpreter to manage objects abstraction between objects
For viewing the concept of the project visit the Wiki.
The console functions are as follows:
*New object creation *Abtraction of objects from a file *Carring out operations on objects *Object destruction
The classe are Manage by the Storage
engine in the FileStorage
Class.
- Style guidelines:
All the development and testing was runned over an operating system Ubuntu 20.04 LTS using programming language Python 3.8.3. The editors used were VIM 8.1.2269, VSCode 1.6.1 and Atom 1.58.0 . Control version using Git 2.25.1.
git clone https://github.com/clementigbinoba/AirBnB_clone
Navigate to the AirBnb
directory:
./console.py
In interactive mode
$ ./console.py
(hbnb) help
Documented commands (type help <topic>):
========================================
EOF help quit
(hbnb)
(hbnb)
(hbnb) quit
$
in Non-interactive mode
$ echo "help" | ./console.py
(hbnb)
Documented commands (type help <topic>):
========================================
EOF help quit
(hbnb)
$
$ cat test_help
help
$
$ cat test_help | ./console.py
(hbnb)
Documented commands (type help <topic>):
========================================
EOF help quit
(hbnb)
$
All the test in the test folder are defined.
- Modules:
python3 -c 'print(__import__("my_module").__doc__)'
- Classes:
python3 -c 'print(__import__("my_module").MyClass.__doc__)'
- Functions (inside and outside a class):
python3 -c 'print(__import__("my_module").my_function.__doc__)'
and
python3 -c 'print(__import__("my_module").MyClass.my_function.__doc__)'
- unittest module
- File extension
.py
- Files and folders star with
test_
- Organization:for
models/base.py
, unit tests in:tests/test_models/test_base.py
- Execution command:
python3 -m unittest discover tests
- or:
python3 -m unittest tests/test_models/test_base.py
echo "python3 -m unittest discover tests" | bash
To run the tests in non-interactive mode, and discover all the test, you can use the command:
python3 -m unittest discover tests
- Begin the console from the interactive mode:
$ ./console.py
(hbnb)
- Use help to see the available commands:
(hbnb) help
Documented commands (type help <topic>):
========================================
EOF all count create destroy help quit show update
(hbnb)
- Quit the console:
(hbnb) quit
$
Commands was displayed through the following format Command / usage / example with output
- Create
Set a new instance of a class. The ID of the class is printed and the instance is saved to the file file.json.
create <class>
(hbnb) create BaseModel
6cfb47c4-a434-4da7-ac03-2122624c3762
(hbnb)
- Show
show <class> <id>
(hbnb) show BaseModel 6cfb47c4-a434-4da7-ac03-2122624c3762
[BaseModel] (a) [BaseModel] (6cfb47c4-a434-4da7-ac03-2122624c3762) {'id': '6cfb47c4-a434-4da7-ac03-2122624c3762', 'created_at': datetime.datetime(2021, 11, 14, 3, 28, 45, 571360), 'updated_at': datetime.datetime(2021, 11, 14, 3, 28, 45, 571389)}
(hbnb)
- Destroy
Deletes an instance of a given class by the given ID. Update the file.json
(hbnb) create User
0c98d2b8-7ffa-42b7-8009-d9d54b69a472
(hbnb) destroy User 0c98d2b8-7ffa-42b7-8009-d9d54b69a472
(hbnb) show User 0c98d2b8-7ffa-42b7-8009-d9d54b69a472
** no instance found **
(hbnb)
- all
Prints all string representation of all instances of a given class. If no class is passed, all classes are printed.
(hbnb) create BaseModel
e45ddda9-eb80-4858-99a9-226d4f08a629
(hbnb) all BaseModel
["[BaseModel] (4c8f7ebc-257f-4ed1-b26b-e7aace459897) [BaseModel] (4c8f7ebc-257f-4ed1-b26b-e7aace459897) {'id': '4c8f7ebc-257f-4ed1-b26b-e7aace459897', 'created_at': datetime.datetime(2021, 11, 13, 22, 19, 19, 447155), 'updated_at': datetime.datetime(2021, 11, 13, 22, 19, 19, 447257), 'name': 'My First Model', 'my_number': 89}"]
["[BaseMode
- count
Prints the instances of a given class.
(hbnb) create City
4e01c33e-2564-42c2-b61c-17e512898bad
(hbnb) create City
e952b772-80a5-41e9-b728-6bc4dc5c21b4
(hbnb) count City
2
(hbnb)
- update
Updates instance based on class name, id, and kwargs passed. Update the file.json
## Authors
<details>
<summary>Clement Igbinoba</summary>
<summary> Abenezer Hailu Tibebu</summary>
<ul>
<li><a href="https://www.github.com/clementigbinoba">Github</a></li>
<li><a href="mailto:[email protected]">e-mail</a></li>
</ul>
</details>
## How to add Author file
`Bash script for generating the list of authors in git repo`
#!/bin/sh
git shortlog -se
| perl -spe 's/^\s+\d+\s+//'
| sed -e '/^CommitSyncScript.*$/d' \
AUTHORS