diff options
Diffstat (limited to 'tests/model_permalink/tests.py')
-rw-r--r-- | tests/model_permalink/tests.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/model_permalink/tests.py b/tests/model_permalink/tests.py new file mode 100644 index 0000000000..049f338c2e --- /dev/null +++ b/tests/model_permalink/tests.py @@ -0,0 +1,27 @@ +from __future__ import absolute_import + +from django.test import TestCase + +from .models import Guitarist + + +class PermalinkTests(TestCase): + urls = 'regressiontests.model_permalink.urls' + + def test_permalink(self): + g = Guitarist(name='Adrien Moignard', slug='adrienmoignard') + self.assertEqual(g.url(), '/guitarists/adrienmoignard/') + + def test_wrapped_docstring(self): + "Methods using the @permalink decorator retain their docstring." + g = Guitarist(name='Adrien Moignard', slug='adrienmoignard') + self.assertEqual(g.url.__doc__, "Returns the URL for this guitarist.") + + def test_wrapped_attribute(self): + """ + Methods using the @permalink decorator can have attached attributes + from other decorators + """ + g = Guitarist(name='Adrien Moignard', slug='adrienmoignard') + self.assertTrue(hasattr(g.url_with_attribute, 'attribute')) + self.assertEqual(g.url_with_attribute.attribute, 'value') |