-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathtest_pipe_support.py
78 lines (62 loc) · 2.06 KB
/
test_pipe_support.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
import os
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 SiriDBAsyncUnixConnection
from testing import parse_args
PIPE_NAME = '/tmp/siridb_pipe_test.sock'
DATA = {
'series num_float': [
[1471254705, 1.5],
[1471254707, -3.5],
[1471254710, -7.3]],
'series num_integer': [
[1471254705, 5],
[1471254708, -3],
[1471254710, -7]],
'series_log': [
[1471254710, 'log line one'],
[1471254712, 'log line two'],
[1471254714, 'another line (three)'],
[1471254716, 'and yet one more']]
}
if os.path.exists(PIPE_NAME):
os.unlink(PIPE_NAME)
class TestPipeSupport(TestBase):
title = 'Test pipe support object'
@default_test_setup(1, pipe_name=PIPE_NAME)
async def run(self):
pipe_client0 = SiriDBAsyncUnixConnection(PIPE_NAME)
await pipe_client0.connect('iris', 'siri', self.db.dbname)
self.assertEqual(
await pipe_client0.insert(DATA),
{'success_msg': 'Successfully inserted 10 point(s).'})
self.assertAlmostEqual(
await pipe_client0.query('select * from "series num_float"'),
{'series num_float': DATA['series num_float']})
self.assertEqual(
await pipe_client0.query('select * from "series num_integer"'),
{'series num_integer': DATA['series num_integer']})
self.assertEqual(
await pipe_client0.query('select * from "series_log"'),
{'series_log': DATA['series_log']})
pipe_client0.close()
if __name__ == '__main__':
parse_args()
run_test(TestPipeSupport())