File: tests.py

package info (click to toggle)
python-django 1.7.7-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 44,872 kB
  • sloc: python: 170,757; xml: 713; makefile: 199; sh: 170; sql: 11
file content (25 lines) | stat: -rw-r--r-- 929 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from django.test import TestCase

from .models import Guitarist


class PermalinkTests(TestCase):
    urls = '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')