Use globals for the database connection
- remove the factory functions for creating engines and sessions - define global engine, connection, and session objects to be used everywhere in the urban_meal_delivery package
This commit is contained in:
parent
f996376b13
commit
2e3ccd14d5
8 changed files with 74 additions and 24 deletions
|
|
@ -36,11 +36,27 @@ def test_database_uri_set(env, monkeypatch):
|
|||
|
||||
|
||||
@pytest.mark.parametrize('env', envs)
|
||||
def test_no_database_uri_set(env, monkeypatch):
|
||||
def test_no_database_uri_set_with_testing_env_var(env, monkeypatch):
|
||||
"""Package does not work without DATABASE_URI set in the environment."""
|
||||
monkeypatch.setattr(configuration.ProductionConfig, 'DATABASE_URI', None)
|
||||
monkeypatch.setattr(configuration.TestingConfig, 'DATABASE_URI', None)
|
||||
|
||||
monkeypatch.setenv('TESTING', 'true')
|
||||
|
||||
with pytest.warns(None) as record:
|
||||
configuration.make_config(env)
|
||||
|
||||
assert len(record) == 0 # noqa:WPS441,WPS507
|
||||
|
||||
|
||||
@pytest.mark.parametrize('env', envs)
|
||||
def test_no_database_uri_set_without_testing_env_var(env, monkeypatch):
|
||||
"""Package does not work without DATABASE_URI set in the environment."""
|
||||
monkeypatch.setattr(configuration.ProductionConfig, 'DATABASE_URI', None)
|
||||
monkeypatch.setattr(configuration.TestingConfig, 'DATABASE_URI', None)
|
||||
|
||||
monkeypatch.delenv('TESTING', raising=False)
|
||||
|
||||
with pytest.warns(UserWarning, match='no DATABASE_URI'):
|
||||
configuration.make_config(env)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue