Beispiel #1
0
def test_valid_alias_save(session):
    """Assert that a valid alias can be saved."""
    identifier = 'CP1234567'
    business = factory_business(identifier)
    alias = Alias(
        alias='ABC Ltd.',
        type='TRANSLATION',
        business_id=business.id
    )
    alias.save()
    assert alias.id
Beispiel #2
0
def test_find_alias_by_id(session):
    """Assert that the method returns correct value."""
    identifier = 'CP1234567'
    business = factory_business(identifier)
    alias = Alias(
        alias='ABC Ltd.',
        type='TRANSLATION',
        business_id=business.id
    )
    alias.save()

    res = Alias.find_by_id(alias.id)

    assert res
    assert res.json == alias.json
Beispiel #3
0
def test_alias_json(session):
    """Assert the json format of alias."""
    identifier = 'CP1234567'
    business = factory_business(identifier)
    alias = Alias(
        alias='ABC Ltd.',
        type='TRANSLATION',
        business_id=business.id
    )
    alias.save()
    alias_json = {
        'id': str(alias.id),
        'name': alias.alias,
        'type': alias.type
    }
    assert alias_json == alias.json
Beispiel #4
0
def test_find_alias_by_business_and_type(session):
    """Assert that the method returns correct value."""
    identifier = 'CP1234567'
    business = factory_business(identifier)
    alias1 = Alias(
        alias='ABC Ltd.',
        type='TRANSLATION',
        business_id=business.id
    )
    alias2 = Alias(
        alias='DEF Ltd.',
        type='DBA',
        business_id=business.id
    )
    alias1.save()
    alias2.save()

    res = Alias.find_by_type(business.id, 'TRANSLATION')

    assert res
    assert len(res) == 1
    assert res[0].alias == 'ABC Ltd.'