3
3
from pprint import pprint as pp
4
4
from os import getenv
5
5
6
+ RESPONSE_ID = '2837643'
6
7
7
8
def mock_push_json (data = None , path = '/' ):
8
- return {'id' : '2837643' }
9
+ return {'id' : RESPONSE_ID }
9
10
10
11
11
12
class TestPush (unittest .TestCase ):
@@ -16,19 +17,16 @@ def setUp(self):
16
17
self .original_push_json = self .client ._push_json
17
18
self .client ._push_json = mock_push_json
18
19
20
+
19
21
def test_push (self ):
20
- assert self .client .push ("templj" , 10.0 ) is True
21
- assert self .client .push ("templj" , 12.0 , date = "2015-01-01 09:00:00" ) is True
22
+ assert self .client .push ("templj" , 10.0 ) is RESPONSE_ID
23
+ assert self .client .push ("templj" , 12.0 , date = "2015-01-01 09:00:00" ) is RESPONSE_ID
22
24
23
- def test_push_with_attributes (self ):
24
- self .client ._push_json = lambda data = None , path = '/' : data
25
25
26
- push = self .client .push ("meta" , 100 , attributes = {
26
+ def test_push_with_attributes (self ):
27
+ assert self .client .push ("meta" , 100 , attributes = {
27
28
'n' : 100
28
- })
29
-
30
- assert self .client .last_push_content ['data' ][0 ]['$meta' ] == 100
31
- assert self .client .last_push_content ['data' ][0 ]['n' ] == 100
29
+ }) is RESPONSE_ID
32
30
33
31
34
32
def test_push_validation (self ):
@@ -43,7 +41,7 @@ def test_insert_all(self):
43
41
{'key' : 'templj' , 'value' : 83.3 },
44
42
{'key' : 'templj' , 'value' : 83.3 , 'date' : "2015-01-01 09:00:00" },
45
43
{'key' : 'templj' , 'value' : 12.3 },
46
- ]) is True
44
+ ]) is RESPONSE_ID
47
45
48
46
self .assertRaises (
49
47
Client .KPIValidationException ,
@@ -67,23 +65,3 @@ def test_last_push(self):
67
65
def test_last_push_with_number (self ):
68
66
self .client ._get_json = lambda data = None , path = '/' : path
69
67
assert self .client .last_push (3 ) == '/lastpushes?limit=3'
70
-
71
-
72
- def test_short (self ):
73
- Client ._push_json = mock_push_json
74
-
75
- assert push ("templj" , 22 , token = self .databox_push_token ) is True
76
-
77
- assert insert_all ([
78
- {
79
- 'key' : 'templj' ,
80
- 'value' : 83.3
81
- },
82
- ], token = self .databox_push_token ) is True
83
-
84
- Client ._get_json = lambda number = None , path = '/' : {
85
- 'err' : [],
86
- 'no_err' : 0
87
- }
88
-
89
- assert last_push (token = self .databox_push_token )['err' ] == []
0 commit comments