@@ -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 ):
@@ -138,7 +138,7 @@ def test_create_data(self):
138
138
data = Data (value = 42 )
139
139
result = aio .create_data ('testfeed' , data )
140
140
self .assertEqual (int (result .value ), 42 )
141
-
141
+
142
142
def test_location_data (self ):
143
143
"""receive_location
144
144
"""
@@ -160,11 +160,41 @@ def test_time_data(self):
160
160
"""receive_time
161
161
"""
162
162
aio = self .get_client ()
163
- time = aio .receive_time ()
163
+ server_time = aio .receive_time ()
164
164
# Check that each value is rx'd properly
165
165
# (should never be None type)
166
- for time_data in time :
166
+ for time_data in server_time :
167
167
self .assertIsNotNone (time_data )
168
+ # Check that the week day was interpreted properly
169
+ adjusted_time = time .localtime (time .mktime (server_time ))
170
+ self .assertEqual (server_time .tm_wday , adjusted_time .tm_wday )
171
+
172
+ def test_parse_time_struct (self ):
173
+ """Ensure the _parse_time_struct method properly handles all 7
174
+ week days. Particularly important to make sure Sunday is 6,
175
+ not -1"""
176
+ # Zero time is a dictionary as would be provided by server
177
+ # (wday is one higher than it should be)
178
+ zero_time = {'year' : 1970 ,
179
+ 'mon' : 1 ,
180
+ 'mday' : 1 ,
181
+ 'hour' : 0 ,
182
+ 'min' : 0 ,
183
+ 'sec' : 0 ,
184
+ 'wday' : 4 ,
185
+ 'yday' : 1 ,
186
+ 'isdst' : 0 }
187
+
188
+ # Create a good struct for each day of the week and make sure
189
+ # the server-style dictionary is parsed correctly
190
+ for k in range (7 ):
191
+ real_struct = time .gmtime (k * 86400 )
192
+ d = zero_time .copy ()
193
+ d ['mday' ] += k
194
+ d ['wday' ] += k
195
+ d ['yday' ] += k
196
+ newd = Client ._parse_time_struct (d )
197
+ self .assertEqual (newd .tm_wday , real_struct .tm_wday )
168
198
169
199
# Test Feed Functionality
170
200
def test_append_by_feed_name (self ):
@@ -269,3 +299,7 @@ def test_receive_group_by_key(self):
269
299
group = io .create_group (Group (name = 'grouprx' ))
270
300
response = io .groups (group .key )
271
301
self .assertEqual (response .key , 'grouprx' )
302
+
303
+
304
+ if __name__ == "__main__" :
305
+ unittest .main ()
0 commit comments