/AirBnB_Clone

An AirBnb clone

Primary LanguagePython

Group project: 0x00. AirBnB clone - The console Task 0 Creating a README.md and authors file Task 1 Write beautiful code that passes the pycodestyle checks. 2. Unittests mandatory All your files, classes, functions must be tested with unit tests 3. BaseModel mandatory Write a class BaseModel that defines all common attributes/methods for other classes:

models/base_model.py Public instance attributes: id: string - assign with an uuid when an instance is created: you can use uuid.uuid4() to generate unique id but don’t forget to convert to a string the goal is to have unique id for each BaseModel created_at: datetime - assign with the current datetime when an instance is created updated_at: datetime - assign with the current datetime when an instance is created and it will be updated every time you change your object str: should print: [] (<self.id>) <self.dict> Public instance methods: save(self): updates the public instance attribute updated_at with the current datetime to_dict(self): returns a dictionary containing all keys/values of dict of the instance: by using self.dict, only instance attributes set will be returned a key class must be added to this dictionary with the class name of the object created_at and updated_at must be converted to string object in ISO format: format: %Y-%m-%dT%H:%M:%S.%f (ex: 2017-06-14T22:31:03.285259) you can use isoformat() of datetime object 4. Create BaseModel from dictionary Previously we created a method to generate a dictionary representation of an instance (method to_dict()).

Now it’s time to re-create an instance with this dictionary representation 5. Store first object mandatory Now we can recreate a BaseModel from another one by using a dictionary representation: 6. Console 0.0.1 mandatory Write a program called console.py that contains the entry point of the command interpreter: 7. Console 0.1 mandatory Update your command interpreter (console.py) to have these commands:

create: Creates a new instance of BaseModel, saves it (to the JSON file) and prints the id. Ex: $ create BaseModel If the class name is missing, print ** class name missing ** (ex: $ create) If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ create MyModel) show: Prints the string representation of an instance based on the class name and id. Ex: $ show BaseModel 1234-1234-1234. If the class name is missing, print ** class name missing ** (ex: $ show) If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ show MyModel) If the id is missing, print ** instance id missing ** (ex: $ show BaseModel) If the instance of the class name doesn’t exist for the id, print ** no instance found ** (ex: $ show BaseModel 121212) destroy: Deletes an instance based on the class name and id (save the change into the JSON file). Ex: $ destroy BaseModel 1234-1234-1234. If the class name is missing, print ** class name missing ** (ex: $ destroy) If the class name doesn’t exist, print ** class doesn't exist ** (ex:$ destroy MyModel) If the id is missing, print ** instance id missing ** (ex: $ destroy BaseModel) If the instance of the class name doesn’t exist for the id, print ** no instance found ** (ex: $ destroy BaseModel 121212) all: Prints all string representation of all instances based or not on the class name. Ex: $ all BaseModel or $ all. The printed result must be a list of strings (like the example below) If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ all MyModel) update: Updates an instance based on the class name and id by adding or updating attribute (save the change into the JSON file). Ex: $ update BaseModel 1234-1234-1234 email "aibnb@mail.com". Usage: update "" Only one attribute can be updated at the time You can assume the attribute name is valid (exists for this model) The attribute value must be casted to the attribute type If the class name is missing, print ** class name missing ** (ex: $ update) If the class name doesn’t exist, print ** class doesn't exist ** (ex: $ update MyModel) If the id is missing, print ** instance id missing ** (ex: $ update BaseModel) If the instance of the class name doesn’t exist for the id, print ** no instance found ** (ex: $ update BaseModel 121212) If the attribute name is missing, print ** attribute name missing ** (ex: $ update BaseModel existing-id) If the value for the attribute name doesn’t exist, print ** value missing ** (ex: $ update BaseModel existing-id first_name) All other arguments should not be used (Ex: $ update BaseModel 1234-1234-1234 email "aibnb@mail.com" first_name "Betty" = $ update BaseModel 1234-1234-1234 email "aibnb@mail.com") id, created_at and updated_at cant’ be updated. You can assume they won’t be passed in the update command Only “simple” arguments can be updated: string, integer and float. You can assume nobody will try to update list of ids or datetime Let’s add some rules:

You can assume arguments are always in the right order Each arguments are separated by a space A string argument with a space must be between double quote The error management starts from the first argument to the last one 8. First User mandatory Write a class User that inherits from BaseModel: 9. More classes! mandatory Write all those classes that inherit from BaseModel: 10. Console 1.0 mandatory Update FileStorage to manage correctly serialization and deserialization of all our new classes: Place, State, City, Amenity and Review

Update your command interpreter (console.py) to allow those actions: show, create, destroy, update and all with all classes created previously.

Enjoy your first console! 11. All instances by class name 12. Count instances File: console.py 13. Show File: console.py 14. Destroy File: console.py 15. Update File: console.py 16. Update from dictionary File: console.py 17. Unittests for the Console! File: tests/test_console.py