reverse code not seperating trial_mode_services

This commit is contained in:
venusbb
2017-10-02 14:26:08 +01:00
parent 7b12b7e03d
commit 33a2909a76
2 changed files with 25 additions and 40 deletions

View File

@@ -22,7 +22,6 @@ def platform_admin():
api_args = {'detailed': True, api_args = {'detailed': True,
'only_active': False, # specifically DO get inactive services 'only_active': False, # specifically DO get inactive services
'include_from_test_key': form.include_from_test_key.data, 'include_from_test_key': form.include_from_test_key.data,
'trial_mode_services': None
} }
if form.start_date.data: if form.start_date.data:
@@ -48,7 +47,6 @@ def platform_admin_services():
api_args = {'detailed': True, api_args = {'detailed': True,
'only_active': False, # specifically DO get inactive services 'only_active': False, # specifically DO get inactive services
'include_from_test_key': form.include_from_test_key.data, 'include_from_test_key': form.include_from_test_key.data,
'trial_mode_services': request.endpoint == 'main.trial_services'
} }
if form.start_date.data: if form.start_date.data:

View File

@@ -72,8 +72,7 @@ def test_should_show_research_and_restricted_mode(
assert response.status_code == 200 assert response.status_code == 200
mock_get_detailed_services.assert_called_once_with({'detailed': True, mock_get_detailed_services.assert_called_once_with({'detailed': True,
'include_from_test_key': True, 'include_from_test_key': True,
'only_active': False, 'only_active': False})
'trial_mode_services': ANY})
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
# get first column in second row, which contains flags as text. # get first column in second row, which contains flags as text.
table_body = page.find_all('table')[0].find_all('tbody')[0] table_body = page.find_all('table')[0].find_all('tbody')[0]
@@ -81,9 +80,9 @@ def test_should_show_research_and_restricted_mode(
assert service_mode == displayed assert service_mode == displayed
@pytest.mark.parametrize('endpoint, expected_services_shown, trial_mode_services', [ @pytest.mark.parametrize('endpoint, expected_services_shown', [
('main.live_services', 1, False), ('main.live_services', 1),
('main.trial_services', 1, True), ('main.trial_services', 1),
]) ])
def test_should_render_platform_admin_page( def test_should_render_platform_admin_page(
client, client,
@@ -91,8 +90,7 @@ def test_should_render_platform_admin_page(
mocker, mocker,
mock_get_detailed_services, mock_get_detailed_services,
endpoint, endpoint,
expected_services_shown, expected_services_shown
trial_mode_services,
): ):
mock_get_user(mocker, user=platform_admin_user) mock_get_user(mocker, user=platform_admin_user)
client.login(platform_admin_user) client.login(platform_admin_user)
@@ -102,14 +100,13 @@ def test_should_render_platform_admin_page(
assert len(page.select('tbody tr')) == expected_services_shown * 2 # one row for SMS, one for email assert len(page.select('tbody tr')) == expected_services_shown * 2 # one row for SMS, one for email
mock_get_detailed_services.assert_called_once_with({'detailed': True, mock_get_detailed_services.assert_called_once_with({'detailed': True,
'include_from_test_key': True, 'include_from_test_key': True,
'only_active': False, 'only_active': False})
'trial_mode_services': trial_mode_services})
@pytest.mark.parametrize('endpoint, trial_mode_services', [ @pytest.mark.parametrize('endpoint', [
('main.platform_admin', None), ('main.platform_admin'),
('main.live_services', False), ('main.live_services'),
('main.trial_services', True), ('main.trial_services'),
]) ])
@pytest.mark.parametrize('include_from_test_key, inc', [ @pytest.mark.parametrize('include_from_test_key, inc', [
("Y", True), ("Y", True),
@@ -122,7 +119,6 @@ def test_platform_admin_toggle_including_from_test_key(
mocker, mocker,
mock_get_detailed_services, mock_get_detailed_services,
endpoint, endpoint,
trial_mode_services,
inc inc
): ):
mock_get_user(mocker, user=platform_admin_user) mock_get_user(mocker, user=platform_admin_user)
@@ -132,21 +128,19 @@ def test_platform_admin_toggle_including_from_test_key(
assert response.status_code == 200 assert response.status_code == 200
mock_get_detailed_services.assert_called_once_with({'detailed': True, mock_get_detailed_services.assert_called_once_with({'detailed': True,
'only_active': False, 'only_active': False,
'trial_mode_services': trial_mode_services,
'include_from_test_key': inc}) 'include_from_test_key': inc})
@pytest.mark.parametrize('endpoint, trial_mode_services', [ @pytest.mark.parametrize('endpoint', [
('main.platform_admin', None), 'main.platform_admin',
('main.live_services', False), 'main.live_services',
('main.trial_services', True) 'main.trial_services'
]) ])
def test_platform_admin_with_date_filter( def test_platform_admin_with_date_filter(
client, client,
platform_admin_user, platform_admin_user,
mocker, mocker,
mock_get_detailed_services, mock_get_detailed_services,
trial_mode_services,
endpoint endpoint
): ):
mock_get_user(mocker, user=platform_admin_user) mock_get_user(mocker, user=platform_admin_user)
@@ -162,7 +156,6 @@ def test_platform_admin_with_date_filter(
'start_date': datetime.date(2016, 12, 20), 'start_date': datetime.date(2016, 12, 20),
'detailed': True, 'detailed': True,
'only_active': False, 'only_active': False,
'trial_mode_services': trial_mode_services,
}) })
@@ -308,15 +301,14 @@ def test_format_stats_by_service_returns_correct_values(fake_uuid):
assert ret[0]['stats']['sms']['failed'] == 11 assert ret[0]['stats']['sms']['failed'] == 11
@pytest.mark.parametrize('endpoint, restricted, research_mode, trial_mode_services', [ @pytest.mark.parametrize('endpoint, restricted, research_mode', [
('main.trial_services', True, False, True), ('main.trial_services', True, False),
('main.live_services', False, False, False) ('main.live_services', False, False)
]) ])
def test_should_show_email_and_sms_stats_for_all_service_types( def test_should_show_email_and_sms_stats_for_all_service_types(
endpoint, endpoint,
restricted, restricted,
research_mode, research_mode,
trial_mode_services,
client, client,
platform_admin_user, platform_admin_user,
mocker, mocker,
@@ -341,7 +333,6 @@ def test_should_show_email_and_sms_stats_for_all_service_types(
assert response.status_code == 200 assert response.status_code == 200
mock_get_detailed_services.assert_called_once_with({'detailed': True, mock_get_detailed_services.assert_called_once_with({'detailed': True,
'include_from_test_key': True, 'include_from_test_key': True,
'trial_mode_services': trial_mode_services,
'only_active': ANY}) 'only_active': ANY})
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
@@ -360,13 +351,12 @@ def test_should_show_email_and_sms_stats_for_all_service_types(
assert sms_failed == 11 assert sms_failed == 11
@pytest.mark.parametrize('endpoint, restricted, trial_mode_services', [ @pytest.mark.parametrize('endpoint, restricted', [
('main.live_services', False, False), ('main.live_services', False),
('main.trial_services', True, True) ('main.trial_services', True)
], ids=['live', 'trial']) ], ids=['live', 'trial'])
def test_should_show_archived_services_last( def test_should_show_archived_services_last(
endpoint, endpoint,
trial_mode_services,
client, client,
platform_admin_user, platform_admin_user,
mocker, mocker,
@@ -390,8 +380,7 @@ def test_should_show_archived_services_last(
assert response.status_code == 200 assert response.status_code == 200
mock_get_detailed_services.assert_called_once_with({'detailed': True, mock_get_detailed_services.assert_called_once_with({'detailed': True,
'include_from_test_key': True, 'include_from_test_key': True,
'only_active': ANY, 'only_active': ANY})
'trial_mode_services': trial_mode_services})
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
table_body = page.find_all('table')[0].find_all('tbody')[0] table_body = page.find_all('table')[0].find_all('tbody')[0]
@@ -462,15 +451,14 @@ def test_should_show_correct_sent_totals_for_platform_admin(
assert sms_total == 40 assert sms_total == 40
@pytest.mark.parametrize('endpoint, restricted, research_mode, trial_mode_services', [ @pytest.mark.parametrize('endpoint, restricted, research_mode', [
('main.trial_services', True, False, True), ('main.trial_services', True, False),
('main.live_services', False, False, False) ('main.live_services', False, False)
]) ])
def test_should_order_services_by_usage_with_inactive_last( def test_should_order_services_by_usage_with_inactive_last(
endpoint, endpoint,
restricted, restricted,
research_mode, research_mode,
trial_mode_services,
client, client,
platform_admin_user, platform_admin_user,
mocker, mocker,
@@ -517,8 +505,7 @@ def test_should_order_services_by_usage_with_inactive_last(
assert response.status_code == 200 assert response.status_code == 200
mock_get_detailed_services.assert_called_once_with({'detailed': True, mock_get_detailed_services.assert_called_once_with({'detailed': True,
'include_from_test_key': True, 'include_from_test_key': True,
'only_active': ANY, 'only_active': ANY})
'trial_mode_services': trial_mode_services})
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
table_body = page.find_all('table')[0].find_all('tbody')[0] table_body = page.find_all('table')[0].find_all('tbody')[0]