Skip to content

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

Notifications You must be signed in to change notification settings

Mohamed-Mostafaaa/AirBnB_clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

img

AirBNB clone Console

hbnb

Description 🏠

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.

About

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

General Use

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

Resources

Read or watch:

  1. cmd module
  2. cmd module in depth
  3. uuid module
  4. datetime
  5. unittest module
  6. args/kwargs
  7. python test cheatsheet
  8. cmd module wiki page
  9. python unittests

Classes 🆑

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

Storage 🛄

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.

Console 💻

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

Using the Console

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

console

Testing 📏

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

Authors ✒️

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published