- Create a Python package fda,mfladsl
- Create a command interpreter in Python using the cmd module
- Usage Unit testing and how to implement it in a large project
- Serialize and deserialize a Class
- Write and read a JSON file
- Use of manage datetime
- Use of UUID
- Use of * args and how to use it
- Use of * kwargs and how to use it
- To handle named arguments in a function.
- Python Scripts
- Python Unit Tests
Directory | Files |
---|---|
Models | Main Class BaseModel and Sub Classes: City, State, Review, User, Amenity, Place. |
Engine | Class FileStorage |
Tests | All project tests |
In order to manage the objects of our program, we create an environment where we can use and execute specific commands that will allow us to manage our program in a more efficient way,
โ AirBnB_clone git:(main) โ ./console.py
(hbnb)help
Documented commands (type help <topic>):
========================================
EOF User all create destroy help quit show
(hbnb)
(hbnb)
(hbnb)
(hbnb)quit
โ AirBnB_clone git:(main) โ
##In non-interactive mode: ๐ฅ๏ธ
โ AirBnB_clone git:(main) โ echo "help" | ./console.py
(hbnb)
Documented commands (type help <topic>):
========================================
EOF User all create destroy help quit show
(hbnb)%
โ AirBnB_clone git:(main) โ
Command to exit the program
โ AirBnB_clone git:(main) โ ./console.py
(hbnb)
(hbnb)quit
โ AirBnB_clone git:(main) โ
Command to exit the program
โ AirBnB_clone git:(main) โ ./console.py
(hbnb)
(hbnb)EOF
โ AirBnB_clone git:(main) โ
Creates a new instance of BaseModel, saves it (to the JSON file) and prints the id.
โ AirBnB_clone git:(main) โ ./console.py
(hbnb)
(hbnb)create
** class name missing **
(hbnb)create MyModel
** class does not exist **
(hbnb)create BaseModel
.9fbd3cc9-3e0b-411b-ac1b-5a8e01b64a1d
(hbnb)
(hbnb)
Prints the string representation of an instance based on the class name and id.
โ AirBnB_clone git:(main) โ ./console.py
(hbnb)
(hbnb)show
** class name missing **
(hbnb)show MyModel
** class doesnt exist **
(hbnb)show BaseModel
** instance id missing **
(hbnb)show BaseModel 121212
** no instance found **
(hbnb)
(hbnb)show 9fbd3cc9-3e0b-411b-ac1b-5a8e01b64a1d
** class doesnt exist **
(hbnb)show BaseModel 9fbd3cc9-3e0b-411b-ac1b-5a8e01b64a1d
[BaseModel] (9fbd3cc9-3e0b-411b-ac1b-5a8e01b64a1d) {'created_at': datetime.datetime(2021, 11, 13, 23, 5, 18, 456036), 'id': '9fbd3cc9-3e0b-411b-ac1b-5a8e01b64a1d', 'updated_at': datetime.datetime(2021, 11, 13, 23, 5, 18, 456053)}
(hbnb)
Deletes an instance based on the class name and id (save the change into the JSON file).
โ AirBnB_clone git:(main) โ ./console.py
(hbnb)
(hbnb)destroy
** class name missing **
(hbnb)destroy MyModel
** class doesnt exist **
(hbnb)destroy BaseModel
** instance id missing **
(hbnb)destroy BaseModel 121212
** no instance found **
(hbnb)destroy BaseModel 9fbd3cc9-3e0b-411b-ac1b-5a8e01b64a1d
(hbnb)
Prints all string representation of all instances based or not on the class name.
โ AirBnB_clone git:(main) โ ./console.py
(hbnb)
(hbnb)all BaseModel
[BaseModel] (d4f94723-c724-4803-a92c-342a69dee1d7) {'created_at': datetime.datetime(2021, 11, 12, 20, 21, 40, 173122), 'id': 'd4f94723-c724-4803-a92c-342a69dee1d7', 'my_number': 89, 'name': 'My_First_Model', 'updated_at': datetime.datetime(2021, 11, 12, 20, 21, 40, 173128)}
[BaseModel] (d7b39e6f-3694-4380-b892-6c79faae9361) {'created_at': datetime.datetime(2021, 11, 12, 20, 21, 42, 356737), 'id': 'd7b39e6f-3694-4380-b892-6c79faae9361', 'my_number': 89, 'name': 'My_First_Model', 'updated_at': datetime.datetime(2021, 11, 12, 20, 21, 42, 356743)}
[BaseModel] (f50daab2-e7b7-4ae9-98fc-5681c59a2fbb) {'created_at': datetime.datetime(2021, 11, 12, 20, 21, 25, 303542), 'id': 'f50daab2-e7b7-4ae9-98fc-5681c59a2fbb', 'my_number': 89, 'name': 'My_First_Model', 'updated_at': datetime.datetime(2021, 11, 12, 20, 21, 25, 303566)}
Updates an instance based on the class name and id by adding or updating attribute (save the change into the JSON file).
`
` ```