AirBnB Console



Description

This repository contains the files and directories to simulate a simple AirBnB Console. It simulates a Command Interpreter to create, update and remove data. It is also supposed to carry out The 0x00. AirBnB clone - The console project at Holberton School.

What could we do with this console?

  • Create a new object (ex: a new User or a new Place)
  • Retrieve an object from a file, a database etc…
  • Do operations on objects (count, compute stats, etc…)
  • Update attributes of an object
  • Destroy an object

Getting the program

In order to download the program use the command:

  • HTTPS:
git clone https://github.com/dalejohgi/AirBnB_clone.git
  • SSH:
git clone git@github.com:dalejohgi/AirBnB_clone.git

Usage:

To initialize the ./console type:

$ ./console.py 
(hbnb) 

help

Used to get a help to understand how console works. Use: help

(hbnb) help

Documented commands (type help <topic>):
========================================
EOF  all  classes  create  destroy  help  quit  show  update

(hbnb)

quit, EOF

Used to quit the console. Use: quit or <ctrl + d>

(hbnb) quit
$

classes

Used to print the avilable classes. Use: classes

(hbnb) classes
BaseModel / User / Place / State / City / Amenity / Review
(hbnb)

create

Used to generate new objects. It's necessary to use it with the previous available classes. Use: create <className>

(hbnb) create BaseModel
3159a6f1-d301-4ebd-be91-5aa712c8a2ea
(hbnb) 

Note that in this process an id was created by default. It will be used later.

show

Used to print the string representation of an object. Use: show <className> <id>

(hbnb) show BaseModel 3159a6f1-d301-4ebd-be91-5aa712c8a2ea
[BaseModel] (3159a6f1-d301-4ebd-be91-5aa712c8a2ea) {'id': '3159a6f1-d301-4ebd-be91-5aa712c8a2ea', 'updated_at': datetime.datetime(2020, 7, 1, 16, 39, 10, 792620), 'created_at': datetime.datetime(2020, 7, 1, 16, 39, 10, 782799)}
(hbnb) 

all

Prints the string representation of all instances. Use: all <className> or all

(hbnb) all BaseModel
["[BaseModel] (b0da7367-5440-4a2e-af47-51970d1b2c4e) {'id': 'b0da7367-5440-4a2e-af47-51970d1b2c4e', 'updated_at': datetime.datetime(2020, 6, 30, 22, 43, 34, 252295), 'created_at': datetime.datetime(2020, 6, 30, 22, 43, 34, 251154)}", "[Place] (b523e341-cce4-4782-a0da-6ad44e47f502) {'id': 'b523e341-cce4-4782-a0da-6ad44e47f502', 'created_at': datetime.datetime(2020, 6, 30, 20, 15, 59, 323067), 'number_rooms': 15, 'updated_at': datetime.datetime(2020, 6, 30, 20, 15, 59, 325976)}", "[BaseModel] (3159a6f1-d301-4ebd-be91-5aa712c8a2ea) {'id': '3159a6f1-d301-4ebd-be91-5aa712c8a2ea', 'updated_at': datetime.datetime(2020, 7, 1, 16, 39, 10, 792620), 'created_at': datetime.datetime(2020, 7, 1, 16, 39, 10, 782799)}"]
(hbnb) 

update

Used to update objects. Use: update <className> <id> <key> <value>

(hbnb) update BaseModel 3159a6f1-d301-4ebd-be91-5aa712c8a2ea name "Nicolas"
(hbnb) 

Note how the value string is specified if the key is expected to contain a string value.

destroy

Used to destroy an object. Use: destroy <className> <id>

(hbnb) destroy BaseModel 3159a6f1-d301-4ebd-be91-5aa712c8a2ea
(hbnb) 

Requirements

Python Scripts.

  • Allowed editors: vi, vim, emacs
  • All your files will be interpreted/compiled on Ubuntu 14.04 LTS using python3 (version 3.4.3)
  • All your files should end with a new line The first line of all your files should be exactly #!/usr/bin/python3
  • A README.md file, at the root of the folder of the project, is mandatory
  • Your code should use the PEP 8 style (version 1.7 or more)
  • All your files must be executable
  • All your modules should have a documentation (python3 -c 'print(__import__("my_module").__doc__)')
  • All your classes should have a documentation (python3 -c 'print(__import__("my_module").MyClass.__doc__)')
  • All your 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 your files should end with a new line
  • All your test files should be inside a folder tests
  • You have to use the unittest module
  • All your test files should be python files (extension: .py)
  • All your test files and folders should start by test_
  • Your 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 your 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 your modules should have a documentation (python3 -c 'print(__import__("my_module").__doc__)')
  • All your classes should have a documentation (python3 -c 'print(__import__("my_module").MyClass.__doc__)')
  • All your 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__)')
  • We strongly encourage you to work together on test cases, so that you don’t miss any edge case

Authors: