Skip to content

Imanolasolo/AirBnB_clone

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

0x00. AirBnB clone - The console

Thank you for visiting this repository which contain the first step towards building first full web application: the AirBnB clone.

hbnb

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.

hbnb

Getting Started πŸƒ

Table of Contents

About

The tasks in this repository cover:

  • Set up in place a parent class (called BaseModel) to take care of the initialization, serialization and deserialization 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 from BaseModel.
  • Create the first abstracted storage engine of the project: File storage.
  • Create all unittests to validate all classes and storage engine.

AirBnB_clone use the following classes and attributes:

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:

Resources πŸ“š

Read or watch :

M

M

NOTE: πŸ““

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.

Requirements

General πŸ“ƒ

  • Allowed editors: vi, vim, emacs.
  • All files will be compiled on Ubuntu 20.04 LTS using python3.
  • 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 the pycodestyle (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__)' and python3 -c 'print(__import__("my_module").MyClass.my_function.__doc__)')

Python Unit Tests πŸ“Œ

  • 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., For models/base_model.py, unit tests must be in: tests/test_models/test_base_model.py.
  • e.g., For models/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__)' and python3 -c 'print(__import__("my_module").MyClass.my_function.__doc__)').

Installation πŸ’»

  • 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
$

interactive

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 Commands: πŸ“‹

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 new instance of BaseModel, saves it (to the JSON file) and prints the id.
  • destroy - Deletes an instance based on the class name and id (save the change into the JSON file).
  • show - Prints the string representation of an instance based on the class name and id.
  • all - Prints all string representation of all instances based or not on the class name.
  • count - Returns count of objects in specified class.
  • update - Updates an instance based on the class name and id by adding or updating attribute (save the change into the JSON file).

Serialization and Deserialization Process: βœ”οΈ

Tasks

  • Process diagram:

process

  • Class_relationship (UML):

console_work

Testing πŸ“

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

testing

Credits

Author(s):blue_book:

Work is owned and maintained by Imanol Asolo and Alex ArΓ©valo.

[email protected]

M M M

[email protected]

M M M

Acknowledgments πŸ“£

Holberton School (providing guidance)

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. Brand

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 73.1%
  • Python 17.3%
  • HTML 5.3%
  • CSS 4.2%
  • Shell 0.1%