Commit 823afd91 by Paul Kilgo

NamedKey.__unicode__: tests and implementation

parent 7a6f561c
...@@ -137,9 +137,13 @@ class ApplicationKey(models.Model): ...@@ -137,9 +137,13 @@ class ApplicationKey(models.Model):
class NamedKey(ApplicationKey): class NamedKey(ApplicationKey):
name = models.CharField(max_length=50, blank=True) name = models.CharField(max_length=50, blank=True)
class Meta: class Meta:
abstract = True abstract = True
def __unicode__(self):
return unicode(self.name)
def clean(self): def clean(self):
if not self.name: if not self.name:
try: try:
......
...@@ -289,6 +289,12 @@ class NamedKeyTestCase(BaseTestCase): ...@@ -289,6 +289,12 @@ class NamedKeyTestCase(BaseTestCase):
) )
self.assertRaises(ValidationError, key.full_clean) self.assertRaises(ValidationError, key.full_clean)
def test_unicode(self):
key = TestNamedKey(basekey=self.key1)
key.full_clean()
key.save()
self.assertEqual(key.name, unicode(key))
class UserKeyTestCase(BaseTestCase): class UserKeyTestCase(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