Skip to content

Commit

Permalink
Modified: yield_config > get_config (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
signebedi committed Mar 25, 2024
1 parent 4b60ff6 commit e98f53e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions libreforms_fastapi/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from libreforms_fastapi.utils.logging import set_logger

from libreforms_fastapi.utils.config import (
yield_config,
get_config,
validate_and_write_configs,
)

Expand Down Expand Up @@ -84,7 +84,7 @@

# Here we set the application config
_env = os.environ.get('ENVIRONMENT', 'development')
config = yield_config(_env)
config = get_config(_env)

if config.DEBUG:
print(config)
Expand Down
8 changes: 4 additions & 4 deletions libreforms_fastapi/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
KeyExpired,
)

from libreforms_fastapi.utils.config import yield_config
from libreforms_fastapi.utils.config import get_config

from libreforms_fastapi.utils.sqlalchemy_models import (
Base,
Expand Down Expand Up @@ -407,7 +407,7 @@ def cli_useradd(username, password, email, opt_out, site_admin, environment):
"""Add a new user to the application."""

# Set ENVIRONMENT
config = yield_config(environment)
config = get_config(environment)

# Run our assumptions check
assert check_configuration_assumptions(config=config)
Expand Down Expand Up @@ -485,7 +485,7 @@ def cli_usermod(username, password, new_email, opt_out, active, site_admin, head


# Set ENVIRONMENT
config = yield_config(environment)
config = get_config(environment)

# Run our assumptions check
assert check_configuration_assumptions(config=config)
Expand Down Expand Up @@ -572,7 +572,7 @@ def cli_id(username, environment):


# Set ENVIRONMENT
config = yield_config(environment)
config = get_config(environment)

# Run our assumptions check
assert check_configuration_assumptions(config=config)
Expand Down
2 changes: 1 addition & 1 deletion libreforms_fastapi/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

else: env_file_path=""

def yield_config(_env=env):
def get_config(_env=env):
if _env == 'production':
return ProductionConfig()
elif _env == 'testing':
Expand Down
4 changes: 2 additions & 2 deletions libreforms_fastapi/utils/pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@

from pydantic.functional_validators import field_validator, model_validator

from libreforms_fastapi.utils.config import yield_config
from libreforms_fastapi.utils.config import get_config

_env = os.environ.get('ENVIRONMENT', 'development')
config = yield_config(_env)
config = get_config(_env)

class ImproperUsernameFormat(Exception):
"""Raised when the username does not meet the regular expression defined in the app config"""
Expand Down
4 changes: 2 additions & 2 deletions libreforms_fastapi/utils/sqlalchemy_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

from sqlalchemy_signing import create_signing_class

from libreforms_fastapi.utils.config import yield_config
from libreforms_fastapi.utils.config import get_config

_env = os.environ.get('ENVIRONMENT', 'development')
config = yield_config(_env)
config = get_config(_env)

Base = declarative_base()

Expand Down
4 changes: 2 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from sqlalchemy.orm import sessionmaker
from sqlalchemy_signing import Signatures
from libreforms_fastapi.utils.sqlalchemy_models import Base, User, Signing, TransactionLog, Group
from libreforms_fastapi.utils.config import yield_config
from libreforms_fastapi.utils.config import get_config

# os.environ["ENVIRONMENT"] = "testing"
config = yield_config(_env="testing")
config = get_config(_env="testing")

# Define a session-scoped fixture for the TestClient and Signatures
@pytest.fixture(scope="session")
Expand Down

0 comments on commit e98f53e

Please sign in to comment.