def test_get_organisation_by_email_address_ignores_gsi_gov_uk( notify_db_session): org = create_organisation() create_domain('example.gov.uk', org.id) found_org = dao_get_organisation_by_email_address( '*****@*****.**') assert org == found_org
def test_post_update_organisation_returns_400_if_domain_is_duplicate( admin_request, notify_db_session): org = create_organisation() org2 = create_organisation(name='Second org') create_domain('same.com', org.id) data = {'domains': ['new.com', 'same.com']} response = admin_request.post('organisation.update_organisation', _data=data, organisation_id=org2.id, _expected_status=400) assert response['message'] == 'Domain already exists'
def test_update_other_organisation_attributes_doesnt_clear_domains( admin_request, notify_db_session, ): org = create_organisation(name='test_org_2') create_domain('example.gov.uk', org.id) admin_request.post('organisation.update_organisation', _data={ 'crown': True, }, organisation_id=org.id, _expected_status=204) assert [domain.domain for domain in org.domains] == ['example.gov.uk']
def test_post_update_organisation_returns_400_if_domain_is_duplicate( admin_request, notify_db_session): org = create_organisation() org2 = create_organisation(name="Second org") create_domain("same.com", org.id) data = {"domains": ["new.com", "same.com"]} response = admin_request.post( "organisation.update_organisation", _data=data, organisation_id=org2.id, _expected_status=400, ) assert response["message"] == "Domain already exists"
def test_update_other_organisation_attributes_doesnt_clear_domains( admin_request, notify_db_session, ): org = create_organisation(name="test_org_2") create_domain("example.gov.uk", org.id) admin_request.post( "organisation.update_organisation", _data={ "crown": True, }, organisation_id=org.id, _expected_status=204, ) assert [domain.domain for domain in org.domains] == ["example.gov.uk"]
def test_get_organisation_by_email_address(domain, expected_org, notify_db_session): org = create_organisation() create_domain('example.gov.uk', org.id) create_domain('test.gov.uk', org.id) another_org = create_organisation(name='Another') create_domain('cabinet-office.gov.uk', another_org.id) create_domain('cabinetoffice.gov.uk', another_org.id) found_org = dao_get_organisation_by_email_address('test@{}'.format(domain)) if expected_org: assert found_org is org else: assert found_org is None
def test_get_organisation_by_domain(admin_request, notify_db_session, domain, expected_status): org = create_organisation() other_org = create_organisation('Other organisation') create_domain('foo.gov.uk', org.id) create_domain('bar.gov.uk', org.id) create_domain('rab.gov.uk', other_org.id) response = admin_request.get( 'organisation.get_organisation_by_domain', _expected_status=expected_status, domain=domain, ) if expected_status == 200: assert response['id'] == str(org.id) else: assert response['result'] == 'error'
def test_get_organisation_by_domain(admin_request, notify_db_session, domain, expected_status): org = create_organisation() other_org = create_organisation("Other organisation") create_domain("foo.gov.uk", org.id) create_domain("bar.gov.uk", org.id) create_domain("rab.gov.uk", other_org.id) response = admin_request.get( "organisation.get_organisation_by_domain", _expected_status=expected_status, domain=domain, ) if expected_status == 200: assert response["id"] == str(org.id) else: assert response["result"] == "error"