This project involves the application of design patterns to develop a phonebook cli with the following advantages:
- High extensibility (Providers' function definitions can be added without complicating the codebase at all)
- Dependency change does not fail the system.
- Databases: PostgreSQL, mongoDB, firestore, sqlalchemy, filesystem
- Interfaces
- Dependency Injection
- Singleton pattern
- db versioning with alembic
add commandline argument for the new provider in the tests file Make sure the test_databases.py tests even when unchanged pass for your newly added providers' logic
pip install coverage
Run tests for each provider in this format:
coverage run tests\test_databases.py postgres
where "postgres" is one of:
- postgres
- mongoDB
- firestore
- sqlite
- filesystem
use -a to append individual tests
coverage run tests\test_databases.py filesystem && coverage run -a tests\test_databases.py sqlite && coverage run -a tests\test_databases.py postgres && coverage run -a tests\test_databases.py mongoDB && coverage run -a tests\test_databases.py firestore
then
coverage report
add this to the testcov.yml file too
Add these files in the /providers folder before running.
[postgresql]
host=****
database=****
port=5432
user=user
password=****
MONGO_URI=****
{
}
Used for db change mgt and versioning to have reversible changes and avoid loss of data during db restructuring. Run:
alembic init alembic
in a virtual env to create the missing alembic.ini in the root dir and then in it, edit the:
sqlalchemy.url = driver://user:pass@localhost/dbname