diff --git a/Makefile b/Makefile index bc07dd0..5b3ddaf 100644 --- a/Makefile +++ b/Makefile @@ -45,7 +45,11 @@ venv_test: make -f MakefileVenv test db_clean: - rm sql_app.db + rm sql_app.db && touch sql_app.db db_fill: pipenv run python database.py + + +db_reset: db_clean db_fill + diff --git a/database.py b/database.py index 655377f..388e28b 100644 --- a/database.py +++ b/database.py @@ -24,10 +24,13 @@ def fill_db(): import crud import random - for _ in range(10): + def _genres(): + random.choice([["Comedy"], ["Comedy", "Drama"], []]) + + for _ in range(3): name = f"fill_db_{random.randint(1, 1000):03}" - out = crud.create_movie(SessionLocal(), name=name) - print(out.name) + out = crud.create_movie(SessionLocal(), title=name, genres=_genres()) + print(out.title) if __name__ == "__main__":