def test_get_counter_does_not_return_spaces(self): obj = Mock() user = MockUser() roles_key(user, obj) # The first time, the counter == 0 increment_counter(obj) # Now there should be a timestamp res = roles_key(user, obj) self.assertTrue(' ' not in res)
def test_incrementing_counter_works(self): obj = Mock() first = get_counter(obj) self.assertEqual(first, 0) increment_counter(obj) second = get_counter(obj) self.assertNotEqual(second, first)
def rulez_invalidate(self): """ This is the default, simple case where the model is related to user, and so invalidating it will force connected users to recalculate their keys In some cases you will want to invalidate the related objects here by incrementing counters for other models in your application """ increment_counter(self)
def test_incrementing_counter_works_for_none(self): increment_counter(None)