Airbnb Clone is a comprehensive web application that replicates Airbnb's functionality, integrating database storage, a back-end API, and front-end interfacing. At present, the project focuses on implementing the back-end console.
Airbnb utilizes various classes:
- BaseModel: Represents the base model with attributes
id
,created_at
, andupdated_at
. - FileStorage: Manages file storage and object serialization.
- User: Inherits from
BaseModel
and includes attributes likeemail
,password
,first_name
, andlast_name
. - State: Inherits from
BaseModel
with attributes likename
. - City: Inherits from
BaseModel
with attributesstate_id
andname
. - Amenity: Inherits from
BaseModel
with thename
attribute. - Place: Inherits from
BaseModel
with numerous attributes likeplace_id
,user_id
, and more. - Review: Inherits from
BaseModel
with attributesplace_id
,user_id
, andtext
.
These classes are managed by the abstracted storage engine defined in the FileStorage
class. Upon initialization, Airbnb Clone creates an instance of FileStorage
called storage
, which loads and reloads data from file.json
. As instances of classes are created, updated, or deleted, storage
keeps the file.json
file synchronized.
The Airbnb Console is a command-line interpreter used to manage the backend of Airbnb Clone. It allows for manipulation of all classes utilized by the application through calls to the storage
object.
The Airbnb Console can be run interactively or non-interactively. In non-interactive mode, you can pipe commands into console.py
, while in interactive mode, you directly run console.py
.
Example (non-interactive mode):
$ echo "help" | ./console.py
Example (interactive mode):
$ ./console.py
The Airbnb Console supports various commands:
- create: Creates a new instance of a given class.
- show: Prints the string representation of a class instance based on an ID.
- destroy: Deletes a class instance based on an ID.
- all: Prints string representations of instances, either of a specific class or all classes.
- count: Retrieves the number of instances of a given class.
- update: Updates a class instance based on an ID with a given attribute or a dictionary of attributes.
Unit tests for the Airbnb Clone project can be found in the tests
folder. You can run the entire test suite or specific test files using Python's unittest
module.
To run the entire test suite:
$ python3 -m unittest discover tests
To run a specific test file:
$ python3 -m unittest tests/test_console.py
- Zalisile Bazil Stuli - GitHub Profile