コード例 #1
0
ファイル: test_dimensions.py プロジェクト: wanaminn/pydruid
    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
コード例 #2
0
    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
コード例 #3
0
ファイル: test_dimensions.py プロジェクト: druid-io/pydruid
    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
コード例 #4
0
ファイル: test_dimensions.py プロジェクト: wanaminn/pydruid
    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
コード例 #5
0
    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