33from pprint import pprint as pp
44from os import getenv
55
6+ RESPONSE_ID = '2837643'
67
78def mock_push_json (data = None , path = '/' ):
8- return {'id' : '2837643' }
9+ return {'id' : RESPONSE_ID }
910
1011
1112class TestPush (unittest .TestCase ):
@@ -16,19 +17,16 @@ def setUp(self):
1617 self .original_push_json = self .client ._push_json
1718 self .client ._push_json = mock_push_json
1819
20+
1921 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
2224
23- def test_push_with_attributes (self ):
24- self .client ._push_json = lambda data = None , path = '/' : data
2525
26- push = self .client .push ("meta" , 100 , attributes = {
26+ def test_push_with_attributes (self ):
27+ assert self .client .push ("meta" , 100 , attributes = {
2728 '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
3230
3331
3432 def test_push_validation (self ):
@@ -43,7 +41,7 @@ def test_insert_all(self):
4341 {'key' : 'templj' , 'value' : 83.3 },
4442 {'key' : 'templj' , 'value' : 83.3 , 'date' : "2015-01-01 09:00:00" },
4543 {'key' : 'templj' , 'value' : 12.3 },
46- ]) is True
44+ ]) is RESPONSE_ID
4745
4846 self .assertRaises (
4947 Client .KPIValidationException ,
@@ -67,23 +65,3 @@ def test_last_push(self):
6765 def test_last_push_with_number (self ):
6866 self .client ._get_json = lambda data = None , path = '/' : path
6967 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