@@ -23,7 +23,7 @@ class TestClient(base.IOTestCase):
23
23
# If your IP isn't put on the list of non-throttled IPs, uncomment the
24
24
# function below to waste time between tests to prevent throttling.
25
25
#def tearDown(self):
26
- time .sleep (30.0 )
26
+ # time.sleep(30.0)
27
27
28
28
# Helper Methods
29
29
def get_client (self ):
@@ -154,7 +154,7 @@ def test_create_data(self):
154
154
data = Data (value = 42 )
155
155
result = aio .create_data ('testfeed' , data )
156
156
self .assertEqual (int (result .value ), 42 )
157
-
157
+
158
158
def test_location_data (self ):
159
159
"""receive_location
160
160
"""
@@ -176,11 +176,41 @@ def test_time_data(self):
176
176
"""receive_time
177
177
"""
178
178
aio = self .get_client ()
179
- time = aio .receive_time ()
179
+ server_time = aio .receive_time ()
180
180
# Check that each value is rx'd properly
181
181
# (should never be None type)
182
- for time_data in time :
182
+ for time_data in server_time :
183
183
self .assertIsNotNone (time_data )
184
+ # Check that the week day was interpreted properly
185
+ adjusted_time = time .localtime (time .mktime (server_time ))
186
+ self .assertEqual (server_time .tm_wday , adjusted_time .tm_wday )
187
+
188
+ def test_parse_time_struct (self ):
189
+ """Ensure the _parse_time_struct method properly handles all 7
190
+ week days. Particularly important to make sure Sunday is 6,
191
+ not -1"""
192
+ # Zero time is a dictionary as would be provided by server
193
+ # (wday is one higher than it should be)
194
+ zero_time = {'year' : 1970 ,
195
+ 'mon' : 1 ,
196
+ 'mday' : 1 ,
197
+ 'hour' : 0 ,
198
+ 'min' : 0 ,
199
+ 'sec' : 0 ,
200
+ 'wday' : 4 ,
201
+ 'yday' : 1 ,
202
+ 'isdst' : 0 }
203
+
204
+ # Create a good struct for each day of the week and make sure
205
+ # the server-style dictionary is parsed correctly
206
+ for k in range (7 ):
207
+ real_struct = time .gmtime (k * 86400 )
208
+ d = zero_time .copy ()
209
+ d ['mday' ] += k
210
+ d ['wday' ] += k
211
+ d ['yday' ] += k
212
+ newd = Client ._parse_time_struct (d )
213
+ self .assertEqual (newd .tm_wday , real_struct .tm_wday )
184
214
185
215
# Test Feed Functionality
186
216
def test_append_by_feed_name (self ):
@@ -286,6 +316,7 @@ def test_receive_group_by_key(self):
286
316
response = io .groups (group .key )
287
317
self .assertEqual (response .key , 'grouprx' )
288
318
319
+
289
320
# Test Dashboard Functionality
290
321
def test_dashboard_create_dashboard (self ):
291
322
io = self .get_client ()
@@ -372,3 +403,7 @@ def test_layout_update_layout(self):
372
403
self .assertEqual (response .lg [0 ]['w' ], 16 )
373
404
io .delete_block (dash .key , block .id )
374
405
io .delete_dashboard (dash .key )
406
+
407
+
408
+ if __name__ == "__main__" :
409
+ unittest .main ()
0 commit comments