Exemple #1
0
def test_entity_find_by_entity_id_no_id(session, auth_mock):  # pylint:disable=unused-argument
    """Assert that an Entity can not be retrieved when no id input or entity not exists."""
    entity = EntityService.find_by_entity_id(None)

    assert entity is None

    entity = EntityService.find_by_entity_id(9999)

    assert entity is None
Exemple #2
0
def test_reset(session, auth_mock):  # pylint: disable=unused-argument
    """Assert that can be reset data by the provided token."""
    user_with_token = TestUserInfo.user_tester
    user_with_token['keycloak_guid'] = TestJwtClaims.tester_role['sub']
    user = factory_user_model(user_info=user_with_token)
    org = factory_org_model(user_id=user.id)
    factory_membership_model(user.id, org.id)
    entity = factory_entity_model(user_id=user.id)

    ResetDataService.reset(TestJwtClaims.tester_role)

    with pytest.raises(BusinessException) as exception:
        UserService.find_by_jwt_token(user_with_token)
    assert exception.value.code == Error.DATA_NOT_FOUND.name

    found_org = OrgService.find_by_org_id(org.id)
    assert found_org is None

    found_entity = EntityService.find_by_entity_id(entity.id)
    assert found_entity is not None
    dictionary = found_entity.as_dict()
    assert dictionary['business_identifier'] == TestEntityInfo.entity1[
        'businessIdentifier']
    assert not dictionary['pass_code_claimed']

    found_memeber = MembershipService.get_members_for_org(org.id)
    assert found_memeber is None
Exemple #3
0
def test_entity_find_by_entity_id(session, auth_mock):  # pylint:disable=unused-argument
    """Assert that an Entity can be retrieved by entity identifier."""
    entity_model = factory_entity_model()
    entity = EntityService(entity_model)

    entity = EntityService.find_by_entity_id(entity.identifier)

    assert entity is not None
    dictionary = entity.as_dict()
    assert dictionary['business_identifier'] == TestEntityInfo.entity1['businessIdentifier']
Exemple #4
0
def test_delete_entity(app, session):  # pylint:disable=unused-argument
    """Assert that an entity can be deleted."""
    entity_model = factory_entity_model()
    entity = EntityService(entity_model)

    org = factory_org_service()

    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()

    entity.delete()

    entity = EntityService.find_by_entity_id(entity.identifier)

    assert entity is None