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))
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'}
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)
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
def test_infra_info_extract_urls(application_name, _type, _value, _result): dict_result = {r['key']: r['url'] for r in _result} list_result = [r['url'] for r in _result] schema = InfraInfo(huskar_client.client, application_name, _type) assert schema.extract_urls(_value) == list_result assert schema.extract_urls(_value, as_dict=True) == dict_result
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
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