From fb3679d2675d05ff56a9bf4bf495055df192bb9c Mon Sep 17 00:00:00 2001 From: Roman Mogilatov Date: Thu, 13 Oct 2016 10:41:50 +0300 Subject: [PATCH] Move fixtures to separate module in movie lister example --- examples/miniapps/movie_lister/app_csv.py | 3 ++- examples/miniapps/movie_lister/app_db.py | 3 ++- examples/miniapps/movie_lister/app_db_csv.py | 5 +++-- examples/miniapps/movie_lister/fixtures.py | 8 ++++++++ examples/miniapps/movie_lister/settings.py | 6 ------ 5 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 examples/miniapps/movie_lister/fixtures.py diff --git a/examples/miniapps/movie_lister/app_csv.py b/examples/miniapps/movie_lister/app_csv.py index e7aaa310..497d4e49 100644 --- a/examples/miniapps/movie_lister/app_csv.py +++ b/examples/miniapps/movie_lister/app_csv.py @@ -16,6 +16,7 @@ import example.db import example.main import settings +import fixtures import dependency_injector.containers as containers import dependency_injector.providers as providers @@ -38,7 +39,7 @@ class CsvApplication(containers.DeclarativeContainer): movie_lister=movies.MoviesModule.movie_lister) init_db = providers.Callable(example.db.init_csv, - movies_data=settings.MOVIES_SAMPLE_DATA, + movies_data=fixtures.MOVIES_SAMPLE_DATA, csv_file_path=settings.MOVIES_CSV_PATH, delimiter=',') diff --git a/examples/miniapps/movie_lister/app_db.py b/examples/miniapps/movie_lister/app_db.py index 708ba287..7eb02e6e 100644 --- a/examples/miniapps/movie_lister/app_db.py +++ b/examples/miniapps/movie_lister/app_db.py @@ -18,6 +18,7 @@ import example.db import example.main import settings +import fixtures import dependency_injector.containers as containers import dependency_injector.providers as providers @@ -45,7 +46,7 @@ class DbApplication(containers.DeclarativeContainer): movie_lister=movies.MoviesModule.movie_lister) init_db = providers.Callable(example.db.init_sqlite, - movies_data=settings.MOVIES_SAMPLE_DATA, + movies_data=fixtures.MOVIES_SAMPLE_DATA, database=ResourcesModule.database) diff --git a/examples/miniapps/movie_lister/app_db_csv.py b/examples/miniapps/movie_lister/app_db_csv.py index de83e12f..b224ba40 100644 --- a/examples/miniapps/movie_lister/app_db_csv.py +++ b/examples/miniapps/movie_lister/app_db_csv.py @@ -18,6 +18,7 @@ import example.db import example.main import settings +import fixtures import dependency_injector.containers as containers import dependency_injector.providers as providers @@ -55,7 +56,7 @@ class DbApplication(containers.DeclarativeContainer): movie_lister=DbMoviesModule.movie_lister) init_db = providers.Callable(example.db.init_sqlite, - movies_data=settings.MOVIES_SAMPLE_DATA, + movies_data=fixtures.MOVIES_SAMPLE_DATA, database=ResourcesModule.database) @@ -66,7 +67,7 @@ class CsvApplication(containers.DeclarativeContainer): movie_lister=CsvMoviesModule.movie_lister) init_db = providers.Callable(example.db.init_csv, - movies_data=settings.MOVIES_SAMPLE_DATA, + movies_data=fixtures.MOVIES_SAMPLE_DATA, csv_file_path=settings.MOVIES_CSV_PATH, delimiter=',') diff --git a/examples/miniapps/movie_lister/fixtures.py b/examples/miniapps/movie_lister/fixtures.py new file mode 100644 index 00000000..0e8805be --- /dev/null +++ b/examples/miniapps/movie_lister/fixtures.py @@ -0,0 +1,8 @@ +"""Fixtures module.""" + + +MOVIES_SAMPLE_DATA = ( + ('The Hunger Games: Mockingjay - Part 2', 2015, 'Francis Lawrence'), + ('The 33', 2015, 'Patricia Riggen'), + ('Star Wars: Episode VII - The Force Awakens', 2015, 'JJ Abrams'), +) diff --git a/examples/miniapps/movie_lister/settings.py b/examples/miniapps/movie_lister/settings.py index 0a9916f8..5aab4184 100644 --- a/examples/miniapps/movie_lister/settings.py +++ b/examples/miniapps/movie_lister/settings.py @@ -9,9 +9,3 @@ import os DATA_DIR = os.path.abspath(os.path.dirname(__file__) + '/data') MOVIES_CSV_PATH = DATA_DIR + '/movies.csv' MOVIES_DB_PATH = DATA_DIR + '/movies.db' - -MOVIES_SAMPLE_DATA = ( - ('The Hunger Games: Mockingjay - Part 2', 2015, 'Francis Lawrence'), - ('The 33', 2015, 'Patricia Riggen'), - ('Star Wars: Episode VII - The Force Awakens', 2015, 'JJ Abrams'), -)