AirBNB clone Console
AirBnb is a complete web application, integrating database storage, a back-end API, and front-end interfacing in a clone of AirBnB.
The project currently only implements the back-end console.
This is the First Project towards our AirBnB clone project at ALX. Done by Mohamed and Eman
This is the first step towards building your first full web application: the AirBnB clone. This first step is very important because you will use what you build during this project with all other following projects: HTML/CSS templating, database storage, API, front-end integration
Step 1. Clone the repository and cd into the repository
Step 2. Inside the repository, there is a "console.py" file which contains the command line interpreter. Run this command in the terminal to see how it works "$ python3 console.py"
Step 3. When this command is run this appears (hbnb)
Step 4. Type ? to view all the commands in the interpreter
Read or watch:
- cmd module
- cmd module in depth
- uuid module
- datetime
- unittest module
- args/kwargs
- python test cheatsheet
- cmd module wiki page
- python unittests
AirBnB utilizes the following classes:
BaseModel | FileStorage | User | State | City | Amenity | Place | Review | |
---|---|---|---|---|---|---|---|---|
PUBLIC INSTANCE ATTRIBUTES | id created_at updated_at |
Inherits from BaseModel |
Inherits from BaseModel |
Inherits from BaseModel |
Inherits from BaseModel |
Inherits from BaseModel |
Inherits from BaseModel |
|
PUBLIC INSTANCE METHODS | save to_dict |
all new save reload |
"" | "" | "" | "" | "" | "" |
PUBLIC CLASS ATTRIBUTES | email password first_name last_name |
name |
state_id name |
name |
city_id user_id name description number_rooms number_bathrooms max_guest price_by_night latitude longitude amenity_ids |
place_id user_id text |
||
PRIVATE CLASS ATTRIBUTES | file_path objects |
The above classes are handled by the abstracted storage engine defined in the FileStorage class.
Every time the backend is initialized, AirBnB instantiates an instance of
FileStorage
called storage
. The storage
object is loaded/re-loaded from
any class instances stored in the JSON file file.json
. As class instances are
created, updated, or deleted, the storage
object is used to register
corresponding changes in the file.json
.
The console is a command line interpreter that permits management of the backend
of AirBnB. It can be used to handle and manipulate all classes utilized by
the application (achieved by calls on the storage
object defined above).
The AirBnB console can be run both interactively and non-interactively.
To run the console in non-interactive mode, pipe any command(s) into an execution
of the file console.py
at the command line.
$ echo "help" | ./console.py
(hbnb)
Documented commands (type help <topic>):
========================================
EOF all count create destroy help quit show update
(hbnb)
$
Alternatively, to use the AirBnB console in interactive mode, run the
file console.py
by itself:
$ ./console.py
While running in interactive mode, the console displays a prompt for input:
$ ./console.py
(hbnb)
To quit the console, enter the command quit
, or input an EOF signal
(ctrl-D
).
$ ./console.py
(hbnb) quit
$
$ ./console.py
(hbnb) EOF
$
All tests should also pass in non-interactive mode: $ echo "python3 -m unittest discover tests" | bash
Unittests for the AirBnB project are defined in the tests folder. To run the entire test suite simultaneously, execute the following command:
$ python3 unittest -m discover tests
Alternatively, you can specify a single test file to run at a time:
$ python3 unittest -m tests/test_console.py
- Mohamed Mostafa <Mohamed-Mostafaaa>
- Eman Elkamel <emanelkamel>