def test_find_checkpoint_nonce_returns_most_recent_checkpoint(self): now = time.time() self.patch(module_time, "time").return_value = now # Create a "checkpoint" nonce created timestamp_threshold + 5 # seconds ago. Nonce.objects.create( token_key='', consumer_key='', key=get_time_string(now - 5 - timestamp_threshold)) # Create a "checkpoint" nonce created timestamp_threshold # seconds ago. checkpoint = Nonce.objects.create( token_key='', consumer_key='', key=get_time_string(now - timestamp_threshold)) # Create a "checkpoint" nonce created 1 second ago. Nonce.objects.create( token_key='', consumer_key='', key=get_time_string(now - 1)) self.assertEqual(checkpoint, find_checkpoint_nonce())
def test_get_time_string_ends_with_suffix(self): now = time.time() self.assertThat(get_time_string(now), StartsWith(key_prefix))
def test_get_time_string_returns_comparable_string(self): now = time.time() self.assertGreater(get_time_string(now + 1), get_time_string(now))