コード例 #1
0
    def test_parses_nested_results(self):
        raw_results = [
            {"column": 1, "column2": "test", "nested": {"a": 1, "b": "str"}},
            {
                "column": 2,
                "column2": "test",
                "column3": "hello",
                "nested": {"a": 2, "b": "str2", "c": "c"},
            },
        ]

        rows, columns = parse_results(raw_results)

        self.assertDictEqual(
            rows[0], {"column": 1, "column2": "test", "nested.a": 1, "nested.b": "str"}
        )
        self.assertDictEqual(
            rows[1],
            {
                "column": 2,
                "column2": "test",
                "column3": "hello",
                "nested.a": 2,
                "nested.b": "str2",
                "nested.c": "c",
            },
        )

        self.assertIsNotNone(_get_column_by_name(columns, "column"))
        self.assertIsNotNone(_get_column_by_name(columns, "column2"))
        self.assertIsNotNone(_get_column_by_name(columns, "column3"))
        self.assertIsNotNone(_get_column_by_name(columns, "nested.a"))
        self.assertIsNotNone(_get_column_by_name(columns, "nested.b"))
        self.assertIsNotNone(_get_column_by_name(columns, "nested.c"))
コード例 #2
0
ファイル: test_mongodb.py プロジェクト: ariarijp/redash
    def test_parses_regular_results(self):
        raw_results = [
            {'column': 1, 'column2': 'test'},
            {'column': 2, 'column2': 'test', 'column3': 'hello'}
        ]
        rows, columns = parse_results(raw_results)

        for i, row in enumerate(rows):
            self.assertDictEqual(row, raw_results[i])

        self.assertIsNotNone(_get_column_by_name(columns, 'column'))
        self.assertIsNotNone(_get_column_by_name(columns, 'column2'))
        self.assertIsNotNone(_get_column_by_name(columns, 'column3'))
コード例 #3
0
    def test_parses_regular_results(self):
        raw_results = [
            {'column': 1, 'column2': 'test'},
            {'column': 2, 'column2': 'test', 'column3': 'hello'}
        ]
        rows, columns = parse_results(raw_results)

        for i, row in enumerate(rows):
            self.assertDictEqual(row, raw_results[i])

        self.assertIsNotNone(_get_column_by_name(columns, 'column'))
        self.assertIsNotNone(_get_column_by_name(columns, 'column2'))
        self.assertIsNotNone(_get_column_by_name(columns, 'column3'))
コード例 #4
0
    def test_parses_regular_results(self):
        raw_results = [
            {"column": 1, "column2": "test"},
            {"column": 2, "column2": "test", "column3": "hello"},
        ]
        rows, columns = parse_results(raw_results)

        for i, row in enumerate(rows):
            self.assertDictEqual(row, raw_results[i])

        self.assertIsNotNone(_get_column_by_name(columns, "column"))
        self.assertIsNotNone(_get_column_by_name(columns, "column2"))
        self.assertIsNotNone(_get_column_by_name(columns, "column3"))
コード例 #5
0
ファイル: test_mongodb.py プロジェクト: co-l-der/Redash
    def test_parses_nested_results(self):
        raw_results = [{
            'column': 1,
            'column2': 'test',
            'nested': {
                'a': 1,
                'b': 'str'
            }
        }, {
            'column': 2,
            'column2': 'test',
            'column3': 'hello',
            'nested': {
                'a': 2,
                'b': 'str2',
                'c': 'c'
            }
        }]

        rows, columns = parse_results(raw_results)

        self.assertDictEqual(rows[0], {
            'column': 1,
            'column2': 'test',
            'nested.a': 1,
            'nested.b': 'str'
        })
        self.assertDictEqual(
            rows[1], {
                'column': 2,
                'column2': 'test',
                'column3': 'hello',
                'nested.a': 2,
                'nested.b': 'str2',
                'nested.c': 'c'
            })

        self.assertIsNotNone(_get_column_by_name(columns, 'column'))
        self.assertIsNotNone(_get_column_by_name(columns, 'column2'))
        self.assertIsNotNone(_get_column_by_name(columns, 'column3'))
        self.assertIsNotNone(_get_column_by_name(columns, 'nested.a'))
        self.assertIsNotNone(_get_column_by_name(columns, 'nested.b'))
        self.assertIsNotNone(_get_column_by_name(columns, 'nested.c'))
コード例 #6
0
ファイル: test_mongodb.py プロジェクト: ariarijp/redash
    def test_parses_nested_results(self):
        raw_results = [
            {'column': 1, 'column2': 'test', 'nested': {
                'a': 1,
                'b': 'str'
            }},
            {'column': 2, 'column2': 'test', 'column3': 'hello', 'nested': {
                'a': 2,
                'b': 'str2',
                'c': 'c'
            }}
        ]

        rows, columns = parse_results(raw_results)

        self.assertDictEqual(rows[0], { 'column': 1, 'column2': 'test', 'nested.a': 1, 'nested.b': 'str' })
        self.assertDictEqual(rows[1], { 'column': 2, 'column2': 'test', 'column3': 'hello', 'nested.a': 2, 'nested.b': 'str2', 'nested.c': 'c' })

        self.assertIsNotNone(_get_column_by_name(columns, 'column'))
        self.assertIsNotNone(_get_column_by_name(columns, 'column2'))
        self.assertIsNotNone(_get_column_by_name(columns, 'column3'))
        self.assertIsNotNone(_get_column_by_name(columns, 'nested.a'))
        self.assertIsNotNone(_get_column_by_name(columns, 'nested.b'))
        self.assertIsNotNone(_get_column_by_name(columns, 'nested.c'))