Skip to content

Commit 025e97e

Browse files
committed
chore: add test for parsing Infinite numbers
1 parent 6fdd78a commit 025e97e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/test_FluxCSVParser.py

+27
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import math
12
import unittest
23
from io import BytesIO
34

@@ -158,6 +159,32 @@ def test_ParseExportFromUserInterface(self):
158159
self.assertFalse(tables[1].columns[1].group)
159160
self.assertTrue(tables[1].columns[2].group)
160161

162+
def test_ParseInf(self):
163+
164+
data = """#group,false,false,true,true,true,true,true,true,true,true,false,false
165+
#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,string,string,string,string,string,string,double,double
166+
#default,_result,,,,,,,,,,,
167+
,result,table,_start,_stop,_field,_measurement,language,license,name,owner,le,_value
168+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,0,0
169+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,10,0
170+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,20,0
171+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,30,0
172+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,40,0
173+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,50,0
174+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,60,0
175+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,70,0
176+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,80,0
177+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,90,0
178+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,+Inf,15
179+
,,0,2021-06-23T06:50:11.897825012Z,2021-06-25T06:50:11.897825012Z,stars,github_repository,C#,MIT License,influxdb-client-csharp,influxdata,-Inf,15
180+
181+
"""
182+
tables = self._parse_to_tables(data=data)
183+
self.assertEqual(1, tables.__len__())
184+
self.assertEqual(12, tables[0].records.__len__())
185+
self.assertEqual(math.inf, tables[0].records[10]["le"])
186+
self.assertEqual(-math.inf, tables[0].records[11]["le"])
187+
161188
@staticmethod
162189
def _parse_to_tables(data: str):
163190
fp = BytesIO(str.encode(data))

0 commit comments

Comments
 (0)