This project is the first version of the AirBnB project, which is an AirBnB clone that includes design, layout, infrastructure and database. In this repository you will find the AirBnB console, which executes specific commands (shown below) to make specific actions.
Pycodestyle was taken into account and implemented for all files.
The FileStorage
class is in charge of managing the storage through a JSON file (file.json
), the instances are created, updated or deleted, all this through a FileStorage instance called storage
.
The console is used to manage the storage of class instances (file.json
), this console can be used and executed in two ways, which are interactive and non-interactive mode.
The following table shows all the commands for storage management and explains how to use them by its format:
Command | Description | Format |
---|---|---|
help | Shows all allowed commands or gives information about a specific command. | help / help <command> |
quit or EOF | Exits the program. | quit |
create | Creates a new instance. | create <classname> |
show | Shows a specific instance by its classname and its id . |
show <classname> <id> |
all | Displays all stored instances or all stored instances of a specific class by its classname . |
all / all <classname> |
update | Updates an instance (adds or modifies attributes) by its classname , id , attribute and its value to add/modify. |
update <classname> <id> <attribute> <attrvalue> |
destroy | Deletes an instance by its classname and its id . |
destroy <classname> <id> |
Interactive mode
$ ./console.py
(hbnb) help
Documented commands (type help <topic>):
========================================
EOF all create destroy help quit show update
(hbnb)
(hbnb)
(hbnb) quit
$
Non-Interactive Mode
$ echo "help" | ./console.py
(hbnb)
Documented commands (type help <topic>):
========================================
EOF all create destroy help quit show update
(hbnb)
$
$ cat test_help
help
$
$ cat test_help | ./console.py
(hbnb)
Documented commands (type help <topic>):
========================================
EOF all create destroy help quit show update
(hbnb)
$
Examples using the Hbnb console
Console execution and help
command implementation to get information about quit
command:
Create
, update
and show
command implementation to create and display a new instance:
Create
, destroy
and all
command implementation to display how the destroy
command works:
Tests were developed and implemented for all the classes of the project using unittest
in a different test environment, in order not to modify the JSON storage working with a file named test_file.json
, which at the end of the tests will be deleted. All tests are in this directory.
To test the classes built in this project this command can be executed:
python3 -m unittest discover tests
To execute a specific test, the next command can be run with the specific path, as it is shown:
python3 -m unittest tests/test_models/test_base_model.py
Juan Esteban Duque |
Felipe Villamizar |
---|