make notify_db fixture private

This commit is contained in:
Leo Hemsted
2022-05-03 17:13:03 +01:00
parent 6181c60f75
commit 6b0d3860bd

View File

@@ -68,7 +68,7 @@ def create_test_db(database_uri):
@pytest.fixture(scope='session')
def notify_db(notify_api, worker_id):
def _notify_db(notify_api, worker_id):
"""
Manages the connection to the database. Generally this shouldn't be used, instead you should use the
`notify_db_session` fixture which also cleans up any data you've got left over after your test run.
@@ -95,7 +95,7 @@ def notify_db(notify_api, worker_id):
@pytest.fixture(scope='function')
def sms_providers(notify_db):
def sms_providers(_notify_db):
"""
In production we randomly choose which provider to use based on their priority. To guarantee tests run the same each
time, make sure we always choose mmg. You'll need to override them in your tests if you wish to do something
@@ -106,17 +106,17 @@ def sms_providers(notify_db):
@pytest.fixture(scope='function')
def notify_db_session(notify_db, sms_providers):
def notify_db_session(_notify_db, sms_providers):
"""
This fixture clears down all non static data after your test run. It yields the sqlalchemy session variable
so you can manually add, commit, etc if needed.
`notify_db_session.commit()`
"""
yield notify_db.session
yield _notify_db.session
notify_db.session.remove()
for tbl in reversed(notify_db.metadata.sorted_tables):
_notify_db.session.remove()
for tbl in reversed(_notify_db.metadata.sorted_tables):
if tbl.name not in ["provider_details",
"key_types",
"branding_type",
@@ -132,8 +132,8 @@ def notify_db_session(notify_db, sms_providers):
"service_callback_type",
"broadcast_channel_types",
"broadcast_provider_types"]:
notify_db.engine.execute(tbl.delete())
notify_db.session.commit()
_notify_db.engine.execute(tbl.delete())
_notify_db.session.commit()
@pytest.fixture