mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-13 09:50:08 -04:00
Standardise provider psuedo fixture data
Previously it was hard to distinguish ids from identifiers from display names (in the case of the email fixtures). Using predictable attributes will also make it easier to convert this dictionaries to proper fixtures.
This commit is contained in:
@@ -8,11 +8,11 @@ from flask import url_for
|
||||
from app.main.views.providers import add_monthly_traffic
|
||||
|
||||
sms_provider_1 = {
|
||||
'id': '6005e192-4738-4962-beec-ebd982d0b03f',
|
||||
'id': 'sms_provider_1-id',
|
||||
'active': True,
|
||||
'priority': 20,
|
||||
'display_name': 'First Domestic SMS Provider',
|
||||
'identifier': 'first_sms_domestic',
|
||||
'display_name': 'SMS Provider 1',
|
||||
'identifier': 'sms_provider_1',
|
||||
'notification_type': 'sms',
|
||||
'updated_at': datetime(2017, 1, 16, 15, 20, 40).isoformat(),
|
||||
'version': 1,
|
||||
@@ -22,11 +22,11 @@ sms_provider_1 = {
|
||||
}
|
||||
|
||||
sms_provider_2 = {
|
||||
'id': '0bd529cd-a0fd-43e5-80ee-b95ef6b0d51f',
|
||||
'id': 'sms_provider_2-id',
|
||||
'active': True,
|
||||
'priority': 10,
|
||||
'display_name': 'Second Domestic SMS Provider',
|
||||
'identifier': 'second_sms_domestic',
|
||||
'display_name': 'SMS Provider 2',
|
||||
'identifier': 'sms_provider_2',
|
||||
'notification_type': 'sms',
|
||||
'updated_at': None,
|
||||
'version': 1,
|
||||
@@ -36,11 +36,11 @@ sms_provider_2 = {
|
||||
}
|
||||
|
||||
email_provider_1 = {
|
||||
'id': '6005e192-4738-4962-beec-ebd982d0b03a',
|
||||
'id': 'email_provider_1-id',
|
||||
'active': True,
|
||||
'priority': 1,
|
||||
'display_name': 'first_email_provider',
|
||||
'identifier': 'first_email',
|
||||
'display_name': 'Email Provider 1',
|
||||
'identifier': 'email_provider_1',
|
||||
'notification_type': 'email',
|
||||
'updated_at': None,
|
||||
'version': 1,
|
||||
@@ -50,11 +50,11 @@ email_provider_1 = {
|
||||
}
|
||||
|
||||
email_provider_2 = {
|
||||
'id': 'email_provider_2-id',
|
||||
'active': True,
|
||||
'priority': 2,
|
||||
'display_name': 'second_email_provider',
|
||||
'identifier': 'second_email',
|
||||
'id': '0bd529cd-a0fd-43e5-80ee-b95ef6b0d51b',
|
||||
'display_name': 'Email Provider 2',
|
||||
'identifier': 'email_provider_2',
|
||||
'notification_type': 'email',
|
||||
'updated_at': None,
|
||||
'version': 1,
|
||||
@@ -64,11 +64,11 @@ email_provider_2 = {
|
||||
}
|
||||
|
||||
sms_provider_intl_1 = {
|
||||
'id': '67c770f5-918e-4afa-a5ff-880b9beb161d',
|
||||
'id': 'sms_provider_intl_1-id',
|
||||
'active': False,
|
||||
'priority': 10,
|
||||
'display_name': 'First International SMS Provider',
|
||||
'identifier': 'first_sms_international',
|
||||
'display_name': 'SMS Provider Intl 1',
|
||||
'identifier': 'sms_provider_intl_1',
|
||||
'notification_type': 'sms',
|
||||
'updated_at': None,
|
||||
'version': 1,
|
||||
@@ -78,11 +78,11 @@ sms_provider_intl_1 = {
|
||||
}
|
||||
|
||||
sms_provider_intl_2 = {
|
||||
'id': '67c770f5-918e-4afa-a5ff-880b9beb161d',
|
||||
'id': 'sms_provider_intl_2-id',
|
||||
'active': False,
|
||||
'priority': 10,
|
||||
'display_name': 'Second International SMS Provider',
|
||||
'identifier': 'second_sms_international',
|
||||
'display_name': 'SMS Provider Intl 2',
|
||||
'identifier': 'sms_provider_intl_2',
|
||||
'notification_type': 'sms',
|
||||
'updated_at': None,
|
||||
'version': 1,
|
||||
@@ -172,8 +172,8 @@ def test_view_providers_shows_all_providers(
|
||||
domestic_sms_first_row = domestic_sms_table.tbody.find_all('tr')[0]
|
||||
table_data = domestic_sms_first_row.find_all('td')
|
||||
|
||||
assert table_data[0].find_all("a")[0]['href'] == '/provider/6005e192-4738-4962-beec-ebd982d0b03f'
|
||||
assert table_data[0].text.strip() == "First Domestic SMS Provider"
|
||||
assert table_data[0].find_all("a")[0]['href'] == '/provider/sms_provider_1-id'
|
||||
assert table_data[0].text.strip() == "SMS Provider 1"
|
||||
assert table_data[1].text.strip() == "20"
|
||||
assert table_data[2].text.strip() == "42"
|
||||
assert table_data[3].text.strip() == "True"
|
||||
@@ -183,8 +183,8 @@ def test_view_providers_shows_all_providers(
|
||||
domestic_sms_second_row = domestic_sms_table.tbody.find_all('tr')[1]
|
||||
table_data = domestic_sms_second_row.find_all('td')
|
||||
|
||||
assert table_data[0].find_all("a")[0]['href'] == '/provider/0bd529cd-a0fd-43e5-80ee-b95ef6b0d51f'
|
||||
assert table_data[0].text.strip() == "Second Domestic SMS Provider"
|
||||
assert table_data[0].find_all("a")[0]['href'] == '/provider/sms_provider_2-id'
|
||||
assert table_data[0].text.strip() == "SMS Provider 2"
|
||||
assert table_data[1].text.strip() == "10"
|
||||
assert table_data[2].text.strip() == "58"
|
||||
assert table_data[3].text.strip() == "True"
|
||||
@@ -194,8 +194,8 @@ def test_view_providers_shows_all_providers(
|
||||
domestic_email_first_row = domestic_email_table.tbody.find_all('tr')[0]
|
||||
domestic_email_table_data = domestic_email_first_row.find_all('td')
|
||||
|
||||
assert domestic_email_table_data[0].find_all("a")[0]['href'] == '/provider/6005e192-4738-4962-beec-ebd982d0b03a'
|
||||
assert domestic_email_table_data[0].text.strip() == "first_email_provider"
|
||||
assert domestic_email_table_data[0].find_all("a")[0]['href'] == '/provider/email_provider_1-id'
|
||||
assert domestic_email_table_data[0].text.strip() == "Email Provider 1"
|
||||
assert domestic_email_table_data[1].text.strip() == "True"
|
||||
assert domestic_email_table_data[2].text.strip() == "None"
|
||||
assert domestic_email_table_data[3].text.strip() == "None"
|
||||
@@ -203,8 +203,8 @@ def test_view_providers_shows_all_providers(
|
||||
domestic_email_second_row = domestic_email_table.tbody.find_all('tr')[1]
|
||||
domestic_email_table_data = domestic_email_second_row.find_all('td')
|
||||
|
||||
assert domestic_email_table_data[0].find_all("a")[0]['href'] == '/provider/0bd529cd-a0fd-43e5-80ee-b95ef6b0d51b'
|
||||
assert domestic_email_table_data[0].text.strip() == "second_email_provider"
|
||||
assert domestic_email_table_data[0].find_all("a")[0]['href'] == '/provider/email_provider_2-id'
|
||||
assert domestic_email_table_data[0].text.strip() == "Email Provider 2"
|
||||
assert domestic_email_table_data[1].text.strip() == "True"
|
||||
assert domestic_email_table_data[2].text.strip() == "None"
|
||||
assert domestic_email_table_data[3].text.strip() == "None"
|
||||
@@ -212,8 +212,8 @@ def test_view_providers_shows_all_providers(
|
||||
international_sms_first_row = international_sms_table.tbody.find_all('tr')[0]
|
||||
table_data = international_sms_first_row.find_all('td')
|
||||
|
||||
assert table_data[0].find_all("a")[0]['href'] == '/provider/67c770f5-918e-4afa-a5ff-880b9beb161d'
|
||||
assert table_data[0].text.strip() == "First International SMS Provider"
|
||||
assert table_data[0].find_all("a")[0]['href'] == '/provider/sms_provider_intl_1-id'
|
||||
assert table_data[0].text.strip() == "SMS Provider Intl 1"
|
||||
assert table_data[1].text.strip() == "False"
|
||||
assert table_data[2].text.strip() == "None"
|
||||
assert table_data[3].text.strip() == "None"
|
||||
@@ -308,7 +308,7 @@ def test_edit_sms_provider_provider_ratio(
|
||||
inputs = page.select('.govuk-input[type="text"]')
|
||||
assert len(inputs) == 2
|
||||
|
||||
first_input = page.select_one('.govuk-input[name="first_sms_domestic"]')
|
||||
first_input = page.select_one('.govuk-input[name="sms_provider_1"]')
|
||||
assert first_input.attrs['value'] == str(sms_provider_1['priority'])
|
||||
|
||||
|
||||
@@ -340,22 +340,22 @@ def test_edit_sms_provider_provider_ratio_only_shows_active_providers(
|
||||
@pytest.mark.parametrize('post_data, expected_calls', [
|
||||
(
|
||||
{
|
||||
sms_provider_1['identifier']: 10,
|
||||
sms_provider_2['identifier']: 90
|
||||
'sms_provider_1': 10,
|
||||
'sms_provider_2': 90
|
||||
},
|
||||
[
|
||||
call(sms_provider_1['id'], 10),
|
||||
call(sms_provider_2['id'], 90),
|
||||
call('sms_provider_1-id', 10),
|
||||
call('sms_provider_2-id', 90),
|
||||
],
|
||||
),
|
||||
(
|
||||
{
|
||||
sms_provider_1['identifier']: 80,
|
||||
sms_provider_2['identifier']: 20
|
||||
'sms_provider_1': 80,
|
||||
'sms_provider_2': 20
|
||||
},
|
||||
[
|
||||
call(sms_provider_1['id'], 80),
|
||||
call(sms_provider_2['id'], 20),
|
||||
call('sms_provider_1-id', 80),
|
||||
call('sms_provider_2-id', 20),
|
||||
],
|
||||
),
|
||||
])
|
||||
@@ -391,15 +391,15 @@ def test_edit_sms_provider_ratio_submit(
|
||||
@pytest.mark.parametrize('post_data, expected_error', [
|
||||
(
|
||||
{
|
||||
sms_provider_1['identifier']: 90,
|
||||
sms_provider_2['identifier']: 20
|
||||
'sms_provider_1': 90,
|
||||
'sms_provider_2': 20
|
||||
},
|
||||
"Must add up to 100%"
|
||||
),
|
||||
(
|
||||
{
|
||||
sms_provider_1['identifier']: 101,
|
||||
sms_provider_2['identifier']: 20
|
||||
'sms_provider_1': 101,
|
||||
'sms_provider_2': 20
|
||||
},
|
||||
"Must be between 0 and 100"
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user