mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
make tests use mmg 100% of the time by default
we randomly choose between sms providers now - this means that tests may sometimes send firetext and sometimes mmg, so we'd need to patch out different HTTP calls, expect different values in sent_by, etc etc. To ensure tests are consistent, add a new fixture that is always used by notify_db_session, which sets the priorities of the sms providers to 100% mmg 0% firetext. if you need to test other values, then you should set the values manually in the test file
This commit is contained in:
@@ -224,17 +224,17 @@ def test_dao_get_provider_stats(notify_db_session):
|
|||||||
assert result[0].created_by_name is None
|
assert result[0].created_by_name is None
|
||||||
assert result[0].current_month_billable_sms == 0
|
assert result[0].current_month_billable_sms == 0
|
||||||
|
|
||||||
assert result[1].identifier == 'mmg'
|
assert result[1].identifier == 'firetext'
|
||||||
assert result[1].display_name == 'MMG'
|
assert result[1].notification_type == 'sms'
|
||||||
assert result[1].supports_international is True
|
assert result[1].supports_international is False
|
||||||
assert result[1].active is True
|
assert result[1].active is True
|
||||||
assert result[1].current_month_billable_sms == 4
|
assert result[1].current_month_billable_sms == 5
|
||||||
|
|
||||||
assert result[2].identifier == 'firetext'
|
assert result[2].identifier == 'mmg'
|
||||||
assert result[2].notification_type == 'sms'
|
assert result[2].display_name == 'MMG'
|
||||||
assert result[2].supports_international is False
|
assert result[2].supports_international is True
|
||||||
assert result[2].active is True
|
assert result[2].active is True
|
||||||
assert result[2].current_month_billable_sms == 5
|
assert result[2].current_month_billable_sms == 4
|
||||||
|
|
||||||
assert result[3].identifier == 'dvla'
|
assert result[3].identifier == 'dvla'
|
||||||
assert result[3].current_month_billable_sms == 0
|
assert result[3].current_month_billable_sms == 0
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import pytest
|
|||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
|
||||||
from app import create_app, db
|
from app import create_app, db
|
||||||
|
from app.dao.provider_details_dao import get_provider_details_by_identifier
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
@@ -90,7 +91,18 @@ def notify_db(notify_api, worker_id):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def notify_db_session(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
|
||||||
|
different.
|
||||||
|
"""
|
||||||
|
get_provider_details_by_identifier('mmg').priority = 100
|
||||||
|
get_provider_details_by_identifier('firetext').priority = 0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='function')
|
||||||
|
def notify_db_session(notify_db, sms_providers):
|
||||||
yield notify_db
|
yield notify_db
|
||||||
|
|
||||||
notify_db.session.remove()
|
notify_db.session.remove()
|
||||||
|
|||||||
Reference in New Issue
Block a user