-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathtest_series.py
120 lines (103 loc) · 3.09 KB
/
test_series.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import asyncio
import functools
import random
import time
from testing import Client
from testing import default_test_setup
from testing import gen_data
from testing import gen_points
from testing import gen_series
from testing import InsertError
from testing import PoolError
from testing import QueryError
from testing import run_test
from testing import Series
from testing import Server
from testing import ServerError
from testing import SiriDB
from testing import TestBase
from testing import UserAuthError
from testing import parse_args
PI = 'ԉ'
Klingon = ' ' + \
'qajunpaQHeylIjmo’ batlh DuSuvqang charghwI’ ‘It.'
data = {
'string': [
[1538660000, "some string value"],
[1538660010, -123456789],
[1538660020, -0.5],
[1538660030, 1/3],
],
'integer': [
[1538660000, 1],
[1538660010, 35.6],
[1538660020, "-50%"],
[1538660030, ""],
[1538660035, "garbage"],
[1538660040, "18446744073709551616"],
[1538660050, "-18446744073709551616"],
],
'double': [
[1538660000, 1.0],
[1538660010, -35],
[1538660010, "-50%"],
[1538660030, ""],
[1538660035, "garbage"],
]
}
expected = {
'string': [
[1538660000, "some string value"],
[1538660010, '-123456789'],
[1538660020, '-0,500000'],
[1538660030, '0,333333'],
],
'integer': [
[1538660000, 1],
[1538660010, 35],
[1538660020, -50],
[1538660030, 0],
[1538660035, 0],
[1538660040, 9223372036854775807],
[1538660050, -9223372036854775808],
],
'double': [
[1538660000, 1.0],
[1538660010, -35.0],
[1538660010, -50.0],
[1538660030, 0.0],
[1538660035, 0.0],
]
}
class TestSeries(TestBase):
title = 'Test series object'
@default_test_setup(1)
async def run(self):
await self.client0.connect()
points = gen_points(n=10)
self.assertEqual(
await self.client0.insert({
PI: points,
Klingon: points
}), {'success_msg': 'Successfully inserted 20 point(s).'})
self.assertEqual(
await self.client0.query('select * from "{}"'.format(PI)),
{PI: sorted(points)})
self.assertEqual(
await self.client0.query('select * from "{}"'.format(Klingon)),
{Klingon: sorted(points)})
self.assertEqual(
await self.client0.insert(data),
{'success_msg': 'Successfully inserted 16 point(s).'})
self.assertAlmostEqual(
await self.client0.query(
'select * from "string", "integer", "double"'),
expected)
self.assertAlmostEqual(
await self.client0.query(
'select * from "x", "string", "integer", "double", "nexist"'),
expected)
self.client0.close()
if __name__ == '__main__':
parse_args()
run_test(TestSeries())