Move fixtures to separate module in movie lister example

This commit is contained in:
Roman Mogilatov 2016-10-13 10:41:50 +03:00
parent 31dfa191f0
commit fb3679d267
5 changed files with 15 additions and 10 deletions

View File

@ -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=',')

View File

@ -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)

View File

@ -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=',')

View File

@ -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'),
)

View File

@ -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'),
)