def get(org_id): """Retrieve the set of contacts associated with the specified org.""" try: response, status = OrgService.get_contacts(org_id), http_status.HTTP_200_OK except BusinessException as exception: response, status = {'code': exception.code, 'message': exception.message}, exception.status_code return response, status
def test_delete_contact_org_link(session, auth_mock): # pylint:disable=unused-argument """Assert that a contact can not be deleted if it's still being used by an entity.""" entity_model = factory_entity_model() entity = EntityService(entity_model) org = factory_org_service() org_dictionary = org.as_dict() org_id = org_dictionary['id'] contact = factory_contact_model() contact_link = ContactLinkModel() contact_link.contact = contact contact_link.entity = entity._model # pylint:disable=protected-access contact_link.org = org._model # pylint:disable=protected-access contact_link.commit() OrgService.delete_contact(org_id=org_id) org = OrgService.find_by_org_id(org_id) response = OrgService.get_contacts(org_id) assert len(response['contacts']) == 0 delete_contact_link = ContactLinkModel.find_by_entity_id(entity.identifier) assert delete_contact_link exist_contact_link = ContactLinkModel.find_by_org_id(org_id) assert not exist_contact_link