-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from GSA-TTS/app-context-refactor
App context refactor
- Loading branch information
Showing
10 changed files
with
166 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
from .base import APP_ENV | ||
|
||
|
||
if APP_ENV == "dev_local" or APP_ENV == "test": | ||
if APP_ENV == "dev_local": | ||
from .development_local import * | ||
elif APP_ENV == "dev_remote": | ||
from .development_remote import * | ||
elif APP_ENV == "test": | ||
from .test import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import logging | ||
import os | ||
from nad_ch.application.interfaces import ApplicationContext | ||
from nad_ch.infrastructure.logger import BasicLogger | ||
from tests.fakes_and_mocks import ( | ||
FakeDataProviderRepository, | ||
FakeDataSubmissionRepository, | ||
FakeStorage, | ||
) | ||
|
||
|
||
DATABASE_URL = os.getenv("DATABASE_URL") | ||
QUEUE_BROKER_URL = os.getenv("QUEUE_BROKER_URL") | ||
QUEUE_BACKEND_URL = os.getenv("QUEUE_BACKEND_URL") | ||
|
||
|
||
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() | ||
|
||
def create_submission_repository(self): | ||
return FakeDataSubmissionRepository() | ||
|
||
def create_logger(self): | ||
return BasicLogger(__name__, logging.DEBUG) | ||
|
||
def create_storage(self): | ||
return FakeStorage() | ||
|
||
def create_task_queue(self): | ||
from nad_ch.infrastructure.task_queue import celery_app, CeleryTaskQueue | ||
|
||
return CeleryTaskQueue(celery_app) | ||
|
||
|
||
def create_app_context(): | ||
return TestApplicationContext() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import os | ||
from celery import Celery | ||
import geopandas as gpd | ||
from nad_ch.application.interfaces import TaskQueue | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters