Skip to content

Commit

Permalink
Adjust ApplicationContext to not initialize a db session in test
Browse files Browse the repository at this point in the history
  • Loading branch information
akuny committed Jan 31, 2024
1 parent 2133994 commit 59c23ec
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions nad_ch/application_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@
FakeStorage,
)

session = create_session_factory(config.DATABASE_URL)


class ApplicationContext:
def __init__(self):
self._session = create_session_factory(config.DATABASE_URL)
self._providers = self.create_provider_repository()
self._submissions = self.create_submission_repository()
self._logger = self.create_logger()
self._storage = self.create_storage()
self._task_queue = self.create_task_queue()

def create_provider_repository(self):
return SqlAlchemyDataProviderRepository(session)
return SqlAlchemyDataProviderRepository(self.session)

def create_submission_repository(self):
return SqlAlchemyDataSubmissionRepository(session)
return SqlAlchemyDataSubmissionRepository(self.session)

def create_logger(self):
return BasicLogger(__name__)
Expand Down Expand Up @@ -82,6 +81,14 @@ def create_storage(self):


class TestApplicationContext(ApplicationContext):
def __init__(self):
self._session = None
self._providers = self.create_provider_repository()
self._submissions = self.create_submission_repository()
self._logger = self.create_logger()
self._storage = self.create_storage()
self._task_queue = self.create_task_queue()

def create_provider_repository(self):
return FakeDataProviderRepository()

Expand Down

0 comments on commit 59c23ec

Please sign in to comment.