Commit 7a6f561c by Paul Kilgo

ApplicationKey.__unicode__: tests and implementation

parent 25f4f921
...@@ -109,6 +109,12 @@ class ApplicationKey(models.Model): ...@@ -109,6 +109,12 @@ class ApplicationKey(models.Model):
class Meta: class Meta:
abstract = True abstract = True
def __unicode__(self):
try:
return unicode(self.basekey)
except Key.DoesNotExist:
return u'(no basekey)'
@property @property
def key(self): def key(self):
return self.basekey.key return self.basekey.key
......
...@@ -230,6 +230,15 @@ class ApplicationKeyTestCase(BaseTestCase): ...@@ -230,6 +230,15 @@ class ApplicationKeyTestCase(BaseTestCase):
def test_last_used_attribute(self): def test_last_used_attribute(self):
self.assertEqual(self.key1.last_used, self.app_key1.last_used) self.assertEqual(self.key1.last_used, self.app_key1.last_used)
def test_unicode1(self):
''' No basekey '''
key = TestApplicationKey()
self.assertEqual('(no basekey)', unicode(key))
def test_unicode2(self):
''' With basekey '''
self.assertEqual(unicode(self.key1), unicode(self.app_key1))
class NamedKeyTestCase(BaseTestCase): class NamedKeyTestCase(BaseTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment