def test_mapping_with_name(self): templates = ConfigTemplates() template = templates.load('instances/tags') overrides = {'tags.required': True} templates.apply_overrides(template, overrides) assert not overrides assert template.get('required') is True
def test_primitive_recurse(self): templates = ConfigTemplates() template = templates.load('instances/http') errors = templates.apply_overrides(template, {'proxy.description.foo.foo': 'bar'}) assert len(errors) == 1 assert errors[0] == 'Template override `proxy.description` does not refer to a mapping'
def test_list_not_found_root(self): templates = ConfigTemplates() template = templates.load('instances/http') errors = templates.apply_overrides(template, {'foo': 'bar'}) assert len(errors) == 1 assert errors[0] == 'Template override has no named mapping `foo`'
def test_list_not_found(self): templates = ConfigTemplates() template = templates.load('instances/http') errors = templates.apply_overrides(template, {'proxy.value.properties.foo.foo': 'bar'}) assert len(errors) == 1 assert errors[0] == 'Template override `proxy.value.properties` has no named mapping `foo`'
def test_mapping_with_branches(self): templates = ConfigTemplates() template = templates.load('init_config/tags.value') errors = templates.apply_overrides(template, {'example': ['foo', 'bar']}) assert not errors assert template == {'example': ['foo', 'bar'], 'type': 'array', 'items': {'type': 'string'}}
def test_list_with_branches(self): templates = ConfigTemplates() template = templates.load('instances/http.skip_proxy') errors = templates.apply_overrides(template, {'description': 'foobar'}) assert not errors assert template == { 'name': 'skip_proxy', 'value': {'example': False, 'type': 'boolean'}, 'description': 'foobar', }
def test_list_replace(self): templates = ConfigTemplates() original_template = templates.load('instances/http') index = next(i for i, item in enumerate(original_template) if item.get('name') == 'skip_proxy') # no cov template = templates.load('instances/http') errors = templates.apply_overrides(template, {'skip_proxy': 'foobar'}) assert not errors assert 'foobar' in template assert template.index('foobar') == index template.remove('foobar') for item in template: assert item.get('name') != 'skip_proxy'
def test_mapping(self): templates = ConfigTemplates() template = templates.load('init_config/tags') errors = templates.apply_overrides(template, {'value.example': ['foo', 'bar']}) assert not errors assert template == { 'name': 'tags', 'value': {'example': ['foo', 'bar'], 'type': 'array', 'items': {'type': 'string'}}, 'description': ( 'A list of tags to attach to every metric and service check emitted by this integration.\n' '\n' 'Learn more about tagging at https://docs.datadoghq.com/tagging\n' ), }