def test_update_contact_no_contact(session): # pylint:disable=unused-argument """Assert that a contact for a non-existent contact cannot be updated.""" org = factory_org_service() org_dictionary = org.as_dict() with pytest.raises(BusinessException) as exception: OrgService.update_contact(org_dictionary['id'], TestContactInfo.contact2) assert exception.value.code == Error.DATA_NOT_FOUND.name
def put(org_id): """Update an existing contact for the specified org.""" request_json = request.get_json() valid_format, errors = schema_utils.validate(request_json, 'contact') if not valid_format: return {'message': schema_utils.serialize(errors)}, http_status.HTTP_400_BAD_REQUEST try: response, status = OrgService.update_contact(org_id, request_json).as_dict(), 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_update_contact(session): # pylint:disable=unused-argument """Assert that a contact for an existing Org can be updated.""" org = factory_org_service() org_dictionary = org.as_dict() contact = OrgService.add_contact(org_dictionary['id'], TestContactInfo.contact1) dictionary = contact.as_dict() assert dictionary['email'] == TestContactInfo.contact1['email'] updated_contact = OrgService.update_contact(org_dictionary['id'], TestContactInfo.contact2) dictionary = updated_contact.as_dict() assert dictionary['email'] == TestContactInfo.contact2['email']