Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tests #2

Open
chrisclark opened this issue Jul 5, 2016 · 0 comments
Open

Adding tests #2

chrisclark opened this issue Jul 5, 2016 · 0 comments

Comments

@chrisclark
Copy link

Here's a test that will verify that the url functions have indeed been decorated:

from django.test import TestCase
from django.conf.urls import url, include
from functools import wraps
from core.url_utils import decorated_url


def spy_decorator(func):
    @wraps(func)
    def wrap(self, *args, **kwargs):
        return func(*args, **kwargs)
    wrap.__spy__ = "spied"
    return wrap


class TestDecoratedUrl(TestCase):

    def test_urls_get_decorated(self):
        urls = [
            url(r'^$', lambda r: "Huzzah!", name='test_url_resolver'),
        ]
        res = decorated_url(r'^foo/', include(urls), wrap=[spy_decorator])
        self.assertEqual(res.resolve('foo/').func.__spy__, 'spied')
        self.assertTrue(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant