@@ -19,55 +19,72 @@ def test_push(self):
1919 assert self .client .push ("templj" , 10.0 ) is True
2020 assert self .client .push ("templj" , 12.0 , date = "2015-01-01 09:00:00" ) is True
2121
22- def test_push_validation (self ):
23- self .assertRaises (
24- Client .KPIValidationException ,
25- lambda : self .client .push (None , None )
26- )
27-
28- def test_insert_all (self ):
29- assert self .client .insert_all ([
30- {'key' : 'templj' , 'value' : 83.3 },
22+ def test_push_with_attributes (self ):
23+ self .client ._push_json = lambda data = None , path = '/' : dict ({
24+ 'status' : 'ok' ,
25+ }.items () + data .items ())
26+
27+ push = self .client .push ("meta" , 100 , attributes = {
28+ 'n' : 100
29+ })
30+
31+ assert self .client .last_push_content ['data' ][0 ]['$meta' ] == 100
32+ assert self .client .last_push_content ['data' ][0 ]['n' ] == 100
33+
34+
35+ def test_push_validation (self ):
36+ self .assertRaises (
37+ Client .KPIValidationException ,
38+ lambda : self .client .push (None , None )
39+ )
40+
41+
42+ def test_insert_all (self ):
43+ assert self .client .insert_all ([
44+ {'key' : 'templj' , 'value' : 83.3 },
45+ {'key' : 'templj' , 'value' : 83.3 , 'date' : "2015-01-01 09:00:00" },
46+ {'key' : 'templj' , 'value' : 12.3 },
47+ ]) is True
48+
49+ self .assertRaises (
50+ Client .KPIValidationException ,
51+ lambda : self .client .insert_all ([
52+ {'value' : 83.3 },
3153 {'key' : 'templj' , 'value' : 83.3 , 'date' : "2015-01-01 09:00:00" },
3254 {'key' : 'templj' , 'value' : 12.3 },
33- ]) is True
34-
35- self .assertRaises (
36- Client .KPIValidationException ,
37- lambda : self .client .insert_all ([
38- {'value' : 83.3 },
39- {'key' : 'templj' , 'value' : 83.3 , 'date' : "2015-01-01 09:00:00" },
40- {'key' : 'templj' , 'value' : 12.3 },
41- ])
42- )
43-
44- def test_last_push (self ):
45- self .client ._push_json = lambda data = None , path = '/' : {
46- 'err' : [],
47- 'no_err' : 0
48- }
49-
50- assert self .client .last_push ()['err' ] == []
51-
52- def test_last_push_with_number (self ):
53- self .client ._push_json = lambda data = None , path = '/' : path
54- assert self .client .last_push (3 ) == '/lastpushes/3'
55-
56- def test_short (self ):
57- Client ._push_json = mock_push_json
58-
59- assert push ("templj" , 22 , token = self .databox_push_token ) is True
60-
61- assert insert_all ([
62- {
63- 'key' : 'templj' ,
64- 'value' : 83.3
65- },
66- ], token = self .databox_push_token ) is True
67-
68- Client ._push_json = lambda data = None , path = '/' : {
69- 'err' : [],
70- 'no_err' : 0
71- }
72-
73- assert last_push (token = self .databox_push_token )['err' ] == []
55+ ])
56+ )
57+
58+
59+ def test_last_push (self ):
60+ self .client ._push_json = lambda data = None , path = '/' : {
61+ 'err' : [],
62+ 'no_err' : 0
63+ }
64+
65+ assert self .client .last_push ()['err' ] == []
66+
67+
68+ def test_last_push_with_number (self ):
69+ self .client ._push_json = lambda data = None , path = '/' : path
70+ assert self .client .last_push (3 ) == '/lastpushes/3'
71+
72+
73+ def test_short (self ):
74+ Client ._push_json = mock_push_json
75+
76+ assert push ("templj" , 22 , token = self .databox_push_token ) is True
77+
78+ assert insert_all ([
79+ {
80+ 'key' : 'templj' ,
81+ 'value' : 83.3
82+ },
83+ ], token = self .databox_push_token ) is True
84+
85+ Client ._push_json = lambda data = None , path = '/' : {
86+ 'err' : [],
87+ 'no_err' : 0
88+ }
89+
90+ assert last_push (token = self .databox_push_token )['err' ] == []
0 commit comments