Thank you for visiting this repository which contain the first step
towards building first full web application
: the AirBnB clone
.
The project currently only implements the back-end console
. The goal of the project is to deploy on your server a simple copy of the AirBnB website
.
The tasks in this repository cover:
- Set up in place a
parent class
(calledBaseModel
) to take care of theinitialization
,serialization
anddeserialization
of future instances. - Create a simple flow of serialization/deserialization: Instance <->
Dictionary
<->JSON string
<-> file. - Create
all classes
used for AirBnB (User
,State
,City
,Place
β¦) that inherit fromBaseModel
. - Create the first abstracted storage engine of the project:
File storage
. - Create all
unittests
tovalidate
all classes and storage engine.
BaseModel | FileStorage | User | Place | State | City | Amenity | 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 |
all new save reload |
all new save reload |
all new save reload |
all new save reload |
all new save reload |
all new save reload |
Public Class Attributes | email password first_name last_name |
city_id user_id name description number_rooms number_bathrms max_guest price_by_night latitude longitude amenity_ids |
name |
state_id name |
name |
place_id user_id text |
||
Private Class Attributes | file_path objects |
Model of Inheritation_Level.png:
Read or watch :
- Python packages
- AirBnB clone
- Python abstract classes
- cmd module
- uuid module
- datetime
- unittest module
- args/kwargs
- Python test cheatsheet
Our Workbook
is created as .md
type notes, we have used the OBSIDIAN
application to be able to view and edit our notes.
In case the reader of this repository wants to view our workbook, please download the OBSIDIAN
application from this link.
- Allowed editors:
vi
,vim
,emacs
. - All files will be compiled on
Ubuntu 20.04
LTS usingpython3
. - All files should end with a new line.
- The first line of all files should be exactly
#!/usr/bin/python3
. - A
README.md
file, at the root of the folder of the project is mandatory. - The
code
should use thepycodestyle
(version 2.7.*) - All files must be executable.
- The length of files will be tested using
wc
. - All modules should have a documentation
(python3 -c 'print(__import__("my_module").__doc__)')
- All classes should have a documentation
(python3 -c 'print(__import__("my_module").MyClass.__doc__)')
- All functions (inside and outside a class) should have a documentation
(python3 -c 'print(__import__("my_module").my_function.__doc__)'
andpython3 -c 'print(__import__("my_module").MyClass.my_function.__doc__)')
- Allowed editors:
vi
,vim
,emacs
. - All files should end with a new line.
- All test files should be inside a folder
tests
. - You have to use the unittest module.
- All test files should be python files
(extension: .py)
. - All test files and folders should start by
test_
. - The file organization in the tests folder should be the same as your project.
e.g.
, Formodels/base_model.py
, unit tests must be in:tests/test_models/test_base_model.py
.e.g.
, Formodels/user.py
, unit tests must be in:tests/test_models/test_user.py
.- All tests should be executed by using this command:
python3 -m unittest discover tests
. - You can also test file by file by using this command:
python3 -m unittest tests/test_models/test_base_model.py
. - All modules should have a documentation
(python3 -c 'print(__import__("my_module").__doc__)')
. - All classes should have a documentation
(python3 -c 'print(__import__("my_module").MyClass.__doc__)')
. - All functions (inside and outside a class) should have a documentation
(python3 -c 'print(__import__("my_module").my_function.__doc__)'
andpython3 -c 'print(__import__("my_module").MyClass.my_function.__doc__)')
.
- Clone this repository:
git clone "https://github.com/Alexoat76/AirBnB_clone"
- Access AirBnb directory:
cd AirBnB_clone.
$ ./console.py
(hbnb) help
Documented commands (type help <topic>):
========================================
EOF help quit
(hbnb)
(hbnb)
(hbnb) quit
$
But also 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)
$
console.py
- The console contains the entry point of the command interpreter.
List of commands this console supports:
help
- Displays all commands available.quit
- Exits console.EOF
-CTRL + D
Exits console.create
- Creates a newinstance
ofBaseModel
, saves it (to theJSON
file) and prints theid
.destroy
- Deletes aninstance
based on the class name andid
(save the change into theJSON
file).show
- Prints the string representation of aninstance
based on the class name andid
.all
- Prints all string representation of allinstances
based or not on the class name.count
- Returns count of objects in specified class.update
- Updates aninstance
based on the class name and id by adding or updating attribute (save the change into theJSON
file).
Process diagram:
Class_relationship (UML):
Unittests for the AirBnB_clone Project
are defined in the tests
folder. To run the entire test suite simultaneously, execute the following command:
$ python3 -m unittest discover tests
Alternatively, you can specify a single test file to run at a time:
$ python3 -m unittest tests/test_console.py
Work is owned and maintained by
Imanol Asolo
and Alex ArΓ©valo
.
This program was written as part of the curriculum for Holberton School. Holberton School is a campus-based full-stack software engineering program that prepares students for careers in the tech industry using project-based peer learning. For more information, please visit this link.