Exemple #1
0
def test_infra_info_update(application_name,
                           _data, _type, _name, _args, _result):
    if _data:
        schema = InfraInfo(huskar_client.client, application_name, _type)
        schema.data = copy.deepcopy(_data)
        schema.save()

    schema = InfraInfo(huskar_client.client, application_name, _type)
    schema.load()
    assert schema.data == _data
    for value in [None, '', 233, []]:
        with raises(ValueError):
            _invalid_args = dict(_args)
            _invalid_args['value'] = value
            schema.update_by_name(_name, **_invalid_args)
    with raises(InfraNameNotExistError):
        _invalid_name = '123'
        schema.update_by_name(_invalid_name, **_args)
    schema.update_by_name(_name, **_args)
    assert schema.data == _result
    schema.save()

    schema = InfraInfo(huskar_client.client, application_name, _type)
    schema.load()
    assert schema.data == _result
Exemple #2
0
def test_infra_info_ok(zk, application_name, _data, _type):
    schema = InfraInfo(huskar_client.client, application_name, _type)
    schema.data = copy.deepcopy(_data)
    schema.save()

    schema = InfraInfo(huskar_client.client, application_name, _type)
    schema.load()
    assert schema.data == _data
    assert schema.stat == zk.exists(schema.path)
Exemple #3
0
def test_infra_info_list(application_name, _data, _type, _name, _result):
    if _data:
        schema = InfraInfo(huskar_client.client, application_name, _type)
        schema.data = copy.deepcopy(_data)
        schema.save()

    schema = InfraInfo(huskar_client.client, application_name, _type)
    schema.load()
    assert schema.data == _data
    assert schema.list_by_infra_name(_name) == list(map(tuple, _result))
Exemple #4
0
def test_infra_info_fail(application_name, _data, _type, _error):
    schema = InfraInfo(huskar_client.client, application_name, _type)
    schema.data = copy.deepcopy(_data)
    with raises(ValidationError) as error:
        schema.save()
    error.match(_error)

    schema = InfraInfo(huskar_client.client, application_name, _type)
    schema.load()
    assert schema.data != _data
Exemple #5
0
def test_infra_info_get(application_name, _data, _type, _name, _args, _result):
    if _data:
        schema = InfraInfo(huskar_client.client, application_name, _type)
        schema.data = copy.deepcopy(_data)
        schema.save()

    schema = InfraInfo(huskar_client.client, application_name, _type)
    schema.load()
    assert schema.data == _data
    assert schema.get_by_name(
        _name, **_args) == {'url': 'sam+redis://redis.10010/overall.alta'}
Exemple #6
0
def test_infra_info_delete(
        application_name, _data, _type, _name, _args, _result):
    if _data:
        schema = InfraInfo(huskar_client.client, application_name, _type)
        schema.data = copy.deepcopy(_data)
        schema.save()

    schema = InfraInfo(huskar_client.client, application_name, _type)
    schema.load()
    assert schema.data == _data
    schema.delete_by_name(_name, **_args)
    assert schema.data == _result