Commit 823afd91 by Paul Kilgo

NamedKey.__unicode__: tests and implementation

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