def test_get_should_not_render_radios_if_org_type_known( client_request, mocker, ): mock_get_organisation_by_domain(mocker, organisation_type="central") page = client_request.get("main.add_service") assert page.select_one("h1").text.strip() == "Name your service" assert page.select_one("input[name=name]")["value"] == "" assert not page.select(".multiple-choice")
def test_get_should_not_render_radios_if_org_type_known( client_request, mocker, ): mock_get_organisation_by_domain(mocker, organisation_type='central') page = client_request.get('main.add_service') assert page.select_one('h1').text.strip() == 'About your service' assert page.select_one('input[name=name]')['value'] == '' assert not page.select('.multiple-choice')
def test_should_add_service_and_redirect_to_tour_when_no_services( mocker, client_request, mock_create_service, mock_create_service_template, mock_get_services_with_no_services, api_user_active, mock_create_or_update_free_sms_fragment_limit, mock_get_all_email_branding, inherited, email_address, posted, persisted, sms_limit, ): api_user_active['email_address'] = email_address client_request.login(api_user_active) mock_get_organisation_by_domain(mocker, organisation_type=inherited) client_request.post( 'main.add_service', _data={ 'name': 'testing the post', 'organisation_type': posted, }, _expected_status=302, _expected_redirect=url_for( 'main.start_tour', service_id=101, template_id="Example%20text%20message%20template", _external=True, ), ) assert mock_get_services_with_no_services.called mock_create_service.assert_called_once_with( service_name='testing the post', organisation_type=persisted, message_limit=50, restricted=True, user_id=api_user_active['id'], email_from='testing.the.post', ) mock_create_service_template.assert_called_once_with( 'Example text message template', 'sms', ( 'Hey ((name)), I’m trying out GC Notify. Today is ' '((day of week)) and my favourite colour is ((colour)).' ), 101, ) assert session['service_id'] == 101 mock_create_or_update_free_sms_fragment_limit.assert_called_once_with(101, sms_limit)
def test_agreement_cant_be_downloaded_unknown_crown_status( logged_in_client, mocker, fake_uuid, ): mock_get_s3_object = mocker.patch( 'app.s3_client.s3_mou_client.get_s3_object', return_value=_MockS3Object()) mock_get_organisation_by_domain( mocker, crown=None, ) response = logged_in_client.get(url_for('main.download_agreement')) assert response.status_code == 404 assert mock_get_s3_object.call_args_list == []
def test_terms_tells_logged_in_users_what_we_know_about_their_agreement( mocker, fake_uuid, client_request, name, agreement_signed, expected_terms_paragraph, expected_terms_link, ): mock_get_organisation_by_domain( mocker, name=name, agreement_signed=agreement_signed, ) terms_page = client_request.get('main.terms') assert normalize_spaces(terms_page.select('main p')[1].text) == expected_terms_paragraph if expected_terms_link: assert terms_page.select_one('main p a')['href'] == expected_terms_link() else: assert not terms_page.select_one('main p').select('a')
def test_downloading_agreement( logged_in_client, mocker, fake_uuid, crown, expected_file_fetched, expected_file_served, ): mock_get_s3_object = mocker.patch( 'app.s3_client.s3_mou_client.get_s3_object', return_value=_MockS3Object(b'foo')) mock_get_organisation_by_domain( mocker, crown=crown, ) response = logged_in_client.get(url_for('main.download_agreement')) assert response.status_code == 200 assert response.get_data() == b'foo' assert response.headers['Content-Type'] == 'application/pdf' assert response.headers['Content-Disposition'] == ( 'attachment; filename="{}"'.format(expected_file_served)) mock_get_s3_object.assert_called_once_with('test-mou', expected_file_fetched)