Ejemplo n.º 1
0
    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())
Ejemplo n.º 2
0
    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())
Ejemplo n.º 3
0
 def test_find_checkpoint_nonce_returns_None_if_no_checkpoint(self):
     self.assertIsNone(find_checkpoint_nonce())
Ejemplo n.º 4
0
 def test_find_checkpoint_nonce_returns_None_if_no_checkpoint(self):
     self.assertIsNone(find_checkpoint_nonce())