Beispiel #1
0
    def test_parse_empty_reponse(self):
        parsed = parse_response(empty_response)

        self.assertIsInstance(parsed, dict)
        self.assertIsNotNone(parsed['columns'])
        self.assertIsNotNone(parsed['rows'])
        self.assertEqual(len(parsed['columns']), 0)
        self.assertEqual(len(parsed['rows']), 0)
Beispiel #2
0
    def test_parse_empty_reponse(self):
        parsed = parse_response(empty_response)

        self.assertIsInstance(parsed, dict)
        self.assertIsNotNone(parsed["columns"])
        self.assertIsNotNone(parsed["rows"])
        self.assertEqual(len(parsed["columns"]), 0)
        self.assertEqual(len(parsed["rows"]), 0)
Beispiel #3
0
    def test_parse_regular_response(self):
        parsed = parse_response(regular_response)

        self.assertIsInstance(parsed, dict)
        self.assertIsNotNone(parsed['columns'])
        self.assertIsNotNone(parsed['rows'])
        self.assertEqual(len(parsed['columns']), 4)
        self.assertEqual(len(parsed['rows']), 2)

        key_col = parsed['columns'][0]
        self.assertEqual(key_col['name'], 'key')
        self.assertEqual(key_col['type'], TYPE_STRING)

        date_col = parsed['columns'][1]
        self.assertEqual(date_col['name'], 'date')
        self.assertEqual(date_col['type'], TYPE_DATETIME)

        count_col = parsed['columns'][2]
        self.assertEqual(count_col['name'], 'count')
        self.assertEqual(count_col['type'], TYPE_INTEGER)

        avg_col = parsed['columns'][3]
        self.assertEqual(avg_col['name'], 'avg')
        self.assertEqual(avg_col['type'], TYPE_FLOAT)

        row_0 = parsed['rows'][0]
        self.assertEqual(row_0['key'], 'Alpha')
        self.assertEqual(row_0['date'], datetime.datetime(2018, 1, 1, 0, 0))
        self.assertEqual(row_0['count'], 10)
        self.assertAlmostEqual(row_0['avg'], 3.14, 2)

        row_1 = parsed['rows'][1]
        self.assertEqual(row_1['key'], 'Beta')
        self.assertEqual(row_1['date'], datetime.datetime(2018, 2, 1, 0, 0))
        self.assertEqual(row_1['count'], 20)
        self.assertAlmostEqual(row_1['avg'], 6.28, 2)
Beispiel #4
0
    def test_parse_regular_response(self):
        parsed = parse_response(regular_response)

        self.assertIsInstance(parsed, dict)
        self.assertIsNotNone(parsed["columns"])
        self.assertIsNotNone(parsed["rows"])
        self.assertEqual(len(parsed["columns"]), 4)
        self.assertEqual(len(parsed["rows"]), 2)

        key_col = parsed["columns"][0]
        self.assertEqual(key_col["name"], "key")
        self.assertEqual(key_col["type"], TYPE_STRING)

        date_col = parsed["columns"][1]
        self.assertEqual(date_col["name"], "date")
        self.assertEqual(date_col["type"], TYPE_DATETIME)

        count_col = parsed["columns"][2]
        self.assertEqual(count_col["name"], "count")
        self.assertEqual(count_col["type"], TYPE_INTEGER)

        avg_col = parsed["columns"][3]
        self.assertEqual(avg_col["name"], "avg")
        self.assertEqual(avg_col["type"], TYPE_FLOAT)

        row_0 = parsed["rows"][0]
        self.assertEqual(row_0["key"], "Alpha")
        self.assertEqual(row_0["date"], datetime.datetime(2018, 1, 1, 0, 0))
        self.assertEqual(row_0["count"], 10)
        self.assertAlmostEqual(row_0["avg"], 3.14, 2)

        row_1 = parsed["rows"][1]
        self.assertEqual(row_1["key"], "Beta")
        self.assertEqual(row_1["date"], datetime.datetime(2018, 2, 1, 0, 0))
        self.assertEqual(row_1["count"], 20)
        self.assertAlmostEqual(row_1["avg"], 6.28, 2)
Beispiel #5
0
    def test_parse_regular_response(self):
        parsed = parse_response(regular_response)

        self.assertIsInstance(parsed, dict)
        self.assertIsNotNone(parsed['columns'])
        self.assertIsNotNone(parsed['rows'])
        self.assertEqual(len(parsed['columns']), 4)
        self.assertEqual(len(parsed['rows']), 2)

        key_col = parsed['columns'][0]
        self.assertEqual(key_col['name'], 'key')
        self.assertEqual(key_col['type'], TYPE_STRING)

        date_col = parsed['columns'][1]
        self.assertEqual(date_col['name'], 'date')
        self.assertEqual(date_col['type'], TYPE_DATETIME)

        count_col = parsed['columns'][2]
        self.assertEqual(count_col['name'], 'count')
        self.assertEqual(count_col['type'], TYPE_INTEGER)

        avg_col = parsed['columns'][3]
        self.assertEqual(avg_col['name'], 'avg')
        self.assertEqual(avg_col['type'], TYPE_FLOAT)

        row_0 = parsed['rows'][0]
        self.assertEqual(row_0['key'], 'Alpha')
        self.assertEqual(row_0['date'], datetime.datetime(2018, 1, 1, 0, 0))
        self.assertEqual(row_0['count'], 10)
        self.assertAlmostEqual(row_0['avg'], 3.14, 2)

        row_1 = parsed['rows'][1]
        self.assertEqual(row_1['key'], 'Beta')
        self.assertEqual(row_1['date'], datetime.datetime(2018, 2, 1, 0, 0))
        self.assertEqual(row_1['count'], 20)
        self.assertAlmostEqual(row_1['avg'], 6.28, 2)