Commit 7a6f561c by Paul Kilgo

ApplicationKey.__unicode__: tests and implementation

parent 25f4f921
......@@ -109,6 +109,12 @@ class ApplicationKey(models.Model):
class Meta:
abstract = True
def __unicode__(self):
return unicode(self.basekey)
except Key.DoesNotExist:
return u'(no basekey)'
def key(self):
return self.basekey.key
......@@ -230,6 +230,15 @@ class ApplicationKeyTestCase(BaseTestCase):
def test_last_used_attribute(self):
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):
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