Giter VIP home page Giter VIP logo

airbnb_clone's Introduction

AirBnB_clone

AirBnB clone

Description

This is the first of several lite clones of the AirBnB. It specifies classes for User, Place, State, City, Amenity, and Review that inherit from the BaseModel class. Instances are serialized and saved to a JSON file then reloaded and deserialized back into instances. Additionally, there is a simple command line interface (CLI) or 'console' that abstracts the process used to create these instances.

Requirements

Python 3.8.5 or later

Usage

The console can run in two modes: interactive and non-interactive:

Interactive mode

To run the console in interactive mode type:

$ ./console.py

This prompt will appear:

(hbnb)

where you can type commands and get output. For example:

(hbnb) all
["[User] (0a7adbf6-ea6f-4447-9e7e-c160687632e7) {'id': '0a7adbf6-ea6f-4447-9e7e-c160687632e7', 'updated_at': datetime.datetime(2018, 6, 13, 23, 38, 38, 231906), 'created_at': datetime.datetime(2018, 6, 13, 23, 38, 38, 231906)}"]

Non-interactive mode

The same commands can be used to run non-interactive mode with some modifications will produce the same results as above:

$ echo "all" | ./console.py
["[User] (0a7adbf6-ea6f-4447-9e7e-c160687632e7) {'id': '0a7adbf6-ea6f-4447-9e7e-c160687632e7', 'updated_at': datetime.datetime(2018, 6, 13, 23, 38, 38, 231906), 'created_at': datetime.datetime(2018, 6, 13, 23, 38, 38, 231906)}"]

You can also use a file that contains the commands you want to run:

$ cat commands.txt
all User
$ cat commands.txt | ./console.py
["[User] (0a7adbf6-ea6f-4447-9e7e-c160687632e7) {'id': '0a7adbf6-ea6f-4447-9e7e-c160687632e7', 'updated_at': datetime.datetime(2018, 6, 13, 23, 38, 38, 231906), 'created_at': datetime.datetime(2018, 6, 13, 23, 38, 38, 231906)}"]

Storage

Instances of classes are saved in a JSON string representation to the file.json file at the root directory. Any modifications (additions, deletions, updates) to the objects are saved automatically to the file. The JSON file serves as a simple database that helps the data persist across sessions.

Tests

Testing is imperative to building any robust program therefore we have included a comprehensive testing suite using the Python unittest module

To run the entire unittest suite in one go, run the following command from the root directory:

$ python3 -m unittest discover tests
............................................................
----------------------------------------------------------------------
Ran 60 tests in 0.017s

OK

If you want to run tests individually, an example would be:

$ python3 -m unittest tests/test_models/test_base_model.py
.....
----------------------------------------------------------------------
Ran 5 tests in 0.003s

OK

Supported Commands

Name Description Use
help Displays help information for a command help [command]
quit Exits/quits the program quit
EOF Exits the program when files are passed into the program N/A
create Creates a new instance of a specified class create [class_name]
show Prints the string representation of an instance show [class_name] [id]
destroy Deletes an instance destroy [class_name] [id]
all Prints the string representation of all instances of a class all or all [class_name] [id]
update Adds or modifies attributes of an instance update [class_name] [id] [attribute] [value]

airbnb_clone's People

Contributors

victor-amonde avatar bollo-omar avatar

Watchers

 avatar

Forkers

victor-amonde

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.