def test_filter_specs(self): delegate_spec = DimensionSpec("dim", "out").build() filter_specs = [ ( ListFilteredSpec(["val1", "val2"]), { "type": "listFiltered", "delegate": delegate_spec, "values": ["val1", "val2"], }, ), ( ListFilteredSpec(["val1", "val2"], is_whitelist=False), { "type": "listFiltered", "delegate": delegate_spec, "values": ["val1", "val2"], "isWhitelist": False, }, ), ( RegexFilteredSpec(r"\w+"), { "type": "regexFiltered", "delegate": delegate_spec, "pattern": "\\w+" }, ), ] for filter_spec, expected_dim_spec in filter_specs: dim_spec = DimensionSpec("dim", "out", filter_spec=filter_spec) actual = dim_spec.build() assert actual == expected_dim_spec
def test_filter_specs(self): delegate_spec = DimensionSpec('dim', 'out').build() filter_specs = [(ListFilteredSpec(['val1', 'val2']), { 'type': 'listFiltered', 'delegate': delegate_spec, 'values': ['val1', 'val2'], }), (ListFilteredSpec(['val1', 'val2'], is_whitelist=False), { 'type': 'listFiltered', 'delegate': delegate_spec, 'values': ['val1', 'val2'], 'isWhitelist': False, }), (RegexFilteredSpec(r'\w+'), { 'type': 'regexFiltered', 'delegate': delegate_spec, 'pattern': '\\w+', })] for filter_spec, expected_dim_spec in filter_specs: dim_spec = DimensionSpec('dim', 'out', filter_spec=filter_spec) actual = dim_spec.build() assert actual == expected_dim_spec
def test_list_filtered_spec(self): dim_spec = DimensionSpec('dim', 'out').build() list_filtered_spec = ListFilteredSpec(['val1', 'val2']) actual = list_filtered_spec.build(dim_spec) expected_dim_spec = {'type': 'default', 'dimension': 'dim', 'outputName': 'out'} expected = { 'type': 'listFiltered', 'delegate': expected_dim_spec, 'values': ['val1', 'val2'], } assert actual == expected
def test_list_filtered_spec(self): dim_spec = DimensionSpec("dim", "out").build() list_filtered_spec = ListFilteredSpec(["val1", "val2"]) actual = list_filtered_spec.build(dim_spec) expected_dim_spec = { "type": "default", "dimension": "dim", "outputName": "out" } expected = { "type": "listFiltered", "delegate": expected_dim_spec, "values": ["val1", "val2"], } assert actual == expected
def test_list_filtered_spec(self): dim_spec = DimensionSpec('dim', 'out').build() list_filtered_spec = ListFilteredSpec(['val1', 'val2']) actual = list_filtered_spec.build(dim_spec) expected_dim_spec = { 'type': 'default', 'dimension': 'dim', 'outputName': 'out' } expected = { 'type': 'listFiltered', 'delegate': expected_dim_spec, 'values': ['val1', 'val2'], } assert actual == expected