コード例 #1
0
ファイル: test_entity.py プロジェクト: stevenc987/sbc-auth
def test_update_contact_no_contact(session):  # pylint:disable=unused-argument
    """Assert that a contact for a non-existent contact cannot be updated."""
    entity_model = factory_entity_model()
    entity = EntityService(entity_model)

    with pytest.raises(BusinessException) as exception:
        entity.update_contact(TestContactInfo.contact2)
    assert exception.value.code == Error.DATA_NOT_FOUND.name
コード例 #2
0
def test_update_contact_no_contact(session):  # pylint:disable=unused-argument
    """Assert that a contact for a non-existent contact cannot be updated."""
    entity_model = factory_entity_model(business_identifier='CP1234567')
    entity = EntityService(entity_model)

    with pytest.raises(BusinessException) as exception:
        entity.update_contact(TEST_UPDATED_CONTACT_INFO)
    assert exception.value.code == Error.DATA_NOT_FOUND.name
コード例 #3
0
ファイル: test_entity.py プロジェクト: shabeeb-aot/sbc-auth
def test_update_contact(session):  # pylint:disable=unused-argument
    """Assert that a contact for an existing Entity can be updated."""
    entity_model = factory_entity_model()
    entity = EntityService(entity_model)
    entity.add_contact(TestContactInfo.contact1)

    dictionary = entity.as_dict()
    assert len(dictionary['contacts']) == 1
    assert dictionary['contacts'][0]['email'] == TestContactInfo.contact1['email']

    entity.update_contact(TestContactInfo.contact2)

    dictionary = None
    dictionary = entity.as_dict()
    assert len(dictionary['contacts']) == 1
    assert dictionary['contacts'][0]['email'] == TestContactInfo.contact2['email']
コード例 #4
0
def test_update_contact(session):  # pylint:disable=unused-argument
    """Assert that a contact for an existing Entity can be updated."""
    entity_model = factory_entity_model(business_identifier='CP1234567')
    entity = EntityService(entity_model)
    entity.add_contact(TEST_CONTACT_INFO)

    dictionary = entity.as_dict()
    assert len(dictionary['contacts']) == 1
    assert dictionary['contacts'][0]['email'] == \
        TEST_CONTACT_INFO['email']

    entity.update_contact(TEST_UPDATED_CONTACT_INFO)

    dictionary = None
    dictionary = entity.as_dict()
    assert len(dictionary['contacts']) == 1
    assert dictionary['contacts'][0]['email'] == \
        TEST_UPDATED_CONTACT_INFO['email']
コード例 #5
0
ファイル: entity.py プロジェクト: nchaturv/sbc-auth
 def put(business_identifier):
     """Update the business contact for the Entity identified by the provided id."""
     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 = EntityService.update_contact(business_identifier, 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
コード例 #6
0
def test_update_contact(app, session):  # pylint:disable=unused-argument
    """Assert that a contact for an entity can be updated."""
    entity_info = {'businessIdentifier': 'CP1234567'}

    with app.app_context():
        entity = EntityService.create_entity(entity_info)
        contact_info = {'emailAddress': '*****@*****.**'}
        EntityService.add_contact(entity.business_identifier, contact_info)

        contact_info['phoneNumber'] = '(555)-555-5555'
        updated_entity = EntityService.update_contact(
            entity.business_identifier, contact_info)

        assert updated_entity

        updated_contact = EntityService.get_contact_for_business(
            updated_entity.business_identifier)

        assert updated_contact is not None
        assert updated_contact.phone == '(555)-555-5555'