Permalink
Browse files

Add basic cache_key property on Resource objects

  • Loading branch information...
jacobb committed May 20, 2014
1 parent e993e86 commit 217487dbe6ba68df0433207fc2d86726d5a3fc81
Showing with 15 additions and 0 deletions.
  1. +10 −0 nap/resources.py
  2. +5 −0 tests/test_resources.py
View
@@ -149,6 +149,16 @@ def to_python(self, for_read=False):
return obj_dict
+ @property
+ def cache_key(self):
+
+ # This really needs to be cleaned up
+ lookup_url = self.objects.get_lookup_url(self)
+ full_url = self.objects.get_full_url(lookup_url)
+ cache_key = self.objects.cache.get_cache_key(self.__class__, full_url)
+
+ return cache_key
+
# properties
@property
def full_url(self):
View
@@ -138,6 +138,11 @@ def test_eq(self):
assert dm != dm3
assert dm != object()
+ def test_cache_key_method(self):
+ dm = SampleResourceModel(slug='some-slug')
+
+ assert dm.cache_key == "note::http://foo.com/v1/note/some-slug/"
+
class TestResourceAuth(object):

0 comments on commit 217487d

Please sign in to comment.