|
| 1 | +import unittest |
1 | 2 | from io import BytesIO
|
2 | 3 |
|
3 | 4 | from urllib3 import HTTPResponse
|
4 | 5 |
|
5 |
| -from influxdb_client.client.flux_csv_parser import FluxCsvParser, FluxSerializationMode |
6 |
| -from tests.base_test import BaseTest |
| 6 | +from influxdb_client.client.flux_csv_parser import FluxCsvParser, FluxSerializationMode, FluxQueryException |
7 | 7 |
|
8 | 8 |
|
9 |
| -class FluxCsvParserTest(BaseTest): |
| 9 | +class FluxCsvParserTest(unittest.TestCase): |
10 | 10 |
|
11 | 11 | def test_one_table(self):
|
12 | 12 | data = "#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,string,string,string,string,long,long,string\n" \
|
@@ -118,6 +118,29 @@ def test_table_index_not_start_at_zero(self):
|
118 | 118 | self.assertEqual(9, tables[1].columns.__len__())
|
119 | 119 | self.assertEqual(7, tables[1].records.__len__())
|
120 | 120 |
|
| 121 | + def test_response_with_error(self): |
| 122 | + data = "#datatype,string,long,string,string,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string\n" \ |
| 123 | + "#group,false,false,true,true,true,true,false,false,true\n" \ |
| 124 | + "#default,t1,,,,,,,,\n" \ |
| 125 | + ",result,table,_field,_measurement,_start,_stop,_time,_value,tag\n" \ |
| 126 | + ",,0,value,python_client_test,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:20:00Z,2,test1\n" \ |
| 127 | + ",,0,value,python_client_test,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:21:40Z,2,test1\n" \ |
| 128 | + ",,0,value,python_client_test,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:23:20Z,2,test1\n" \ |
| 129 | + ",,0,value,python_client_test,2010-02-27T04:48:32.752600083Z,2020-02-27T16:48:32.752600083Z,2020-02-27T16:25:00Z,2,test1\n" \ |
| 130 | + "\n" \ |
| 131 | + "#datatype,string,string\n" \ |
| 132 | + "#group,true,true\n" \ |
| 133 | + "#default,,\n" \ |
| 134 | + ",error,reference\n" \ |
| 135 | + ",\"engine: unknown field type for value: xyz\"," |
| 136 | + |
| 137 | + with self.assertRaises(FluxQueryException) as cm: |
| 138 | + self._parse_to_tables(data=data) |
| 139 | + exception = cm.exception |
| 140 | + |
| 141 | + self.assertEqual('engine: unknown field type for value: xyz', exception.message) |
| 142 | + self.assertEqual('', exception.reference) |
| 143 | + |
121 | 144 | @staticmethod
|
122 | 145 | def _parse_to_tables(data: str):
|
123 | 146 | fp = BytesIO(str.encode(data))
|
|
0 commit comments