def test_cleanupNonces(self):

        # use valid and expired nonces
        for i in range(10):
            # first 5 are valid rest is expired
            timestamp = time.time() if i < 5 else i
            salt = 'valid' if i < 5 else 'expired'
            NDBOpenIDStore.useNonce('server_url', timestamp, salt)

        query = NDBOpenIDStore.query()

        # check whether all nonces are in the datastore
        assert query.count() == 10

        # call the tested method
        deleted = NDBOpenIDStore.cleanupNonces()

        # check whether the returned value corresponds with the number of deleted nonces
        assert deleted == 5

        # check whether there there are 5 less nonces
        assert query.count() == 5

        # call the tested method again
        deleted = NDBOpenIDStore.cleanupNonces()
        # the returned value should now be 0
        assert deleted == 0

        # check whether there still are 5 valid nonces
        assert query.count() == 5
Exemple #2
0
 def test_cleanupNonces(self):
     
     # use valid and expired nonces
     for i in range(10):
         # first 5 are valid rest is expired
         timestamp = time.time() if i < 5 else i
         salt = 'valid' if i < 5 else 'expired'
         NDBOpenIDStore.useNonce('server_url', timestamp, salt)
     
     query = NDBOpenIDStore.query()
     
     # check whether all nonces are in the datastore
     assert query.count() == 10
                     
     # call the tested method
     deleted = NDBOpenIDStore.cleanupNonces()
     
     # check whether the returned value corresponds with the number of deleted nonces
     assert deleted == 5
     
     # check whether there there are 5 less nonces
     assert query.count() == 5
     
     # call the tested method again
     deleted = NDBOpenIDStore.cleanupNonces()
     # the returned value should now be 0
     assert deleted == 0
     
     # check whether there still are 5 valid nonces
     assert query.count() == 5