def test_key_incr(self, epoch_mock): epoch_mock.return_value = 123456 cache_ns_key(self.namespace) # Sets ns to 123456 ns_key = cache_ns_key(self.namespace, increment=True) expected = '123457:ns:%s' % self.namespace eq_(ns_key, expected) eq_(cache_ns_key(self.namespace), expected)
def get_key(cls, key=None, invalidate=False): namespace = 'riscore' if not key: # Assuming we're invalidating the namespace. cache_ns_key(namespace, invalidate) return else: # Using cache_ns_key so each cache val is invalidated together. ns_key = cache_ns_key(namespace, invalidate) return '%s:%s' % (ns_key, key)
def test_no_preexisting_key_incr(self, epoch_mock): epoch_mock.return_value = 123456 eq_(cache_ns_key(self.namespace, increment=True), '123456:ns:%s' % self.namespace)
def test_no_preexisting_key(self, epoch_mock): epoch_mock.return_value = 123456 eq_(cache_ns_key(self.namespace), "123456:ns:%s" % self.namespace)