forked from IntegriChain1/s3parq
-
Notifications
You must be signed in to change notification settings - Fork 0
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 IntegriChain1#37 from norton120/update-session-man…
…ager Makes Session Manager Work for UAT / Prod
- Loading branch information
Showing
8 changed files
with
95 additions
and
51 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 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 |
---|---|---|
@@ -1,24 +1,33 @@ | ||
from core.constants import ENVIRONMENT | ||
from core.helpers.configuration_mocker import ConfigurationMocker as CMock | ||
import core.models.configuration as config | ||
from sqlalchemy.orm.session import Session | ||
from core.logging import LoggerMixin | ||
|
||
class SessionHelper: | ||
class SessionHelper(LoggerMixin): | ||
""" Gets the correct env-based configuration secret, | ||
returns a session to the right configuration db. | ||
For the dev env it pre-populates the database with helper seed data. | ||
""" | ||
|
||
def __init__(self): | ||
self._session = None | ||
self.logger.info(f"Creating session for {ENVIRONMENT} environment...") | ||
if ENVIRONMENT == "dev": | ||
cmock = CMock() | ||
cmock.generate_mocks() | ||
self._session = cmock.get_session() | ||
elif ENVIRONMENT == "prod": | ||
pass | ||
self.logger.info("Done. Created dev session with mock data.") | ||
if ENVIRONMENT in ("prod", "uat"): | ||
engine = config.GenerateEngine().get_engine() | ||
session = config.Session(engine) | ||
self._session = session.get_session() | ||
self.logger.info(f"Done. Created {ENVIRONMENT} session.") | ||
|
||
@property | ||
def session(self)-> Session: | ||
return self._session | ||
|
||
@session.setter | ||
def session(self,session)->None: | ||
def session(self, session)->None: | ||
raise ValueError("session cannot be explicitly set in session_helper.") |
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