Skip to content

Commit 08ef429

Browse files
committed
Unit test custom urlconf in RavenResolver
1 parent 2e18af2 commit 08ef429

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from __future__ import absolute_import
2+
3+
import django
4+
5+
if django.VERSION >= (2, 0):
6+
# TODO: once we stop supporting django < 2, use the real name of this
7+
# function (re_path)
8+
from django.urls import re_path as url
9+
else:
10+
from django.conf.urls import url
11+
12+
13+
urlpatterns = [
14+
url(r"^foo/bar/baz/(?P<param>[\d]+)", lambda x: ""),
15+
]

tests/integrations/django/test_transactions.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,19 @@ def test_legacy_resolver_newstyle_django20_urlconf():
6161
resolver = RavenResolver()
6262
result = resolver.resolve("/api/v2/1234/store/", url_conf)
6363
assert result == "/api/v2/{project_id}/store/"
64+
65+
66+
def test_legacy_resolver_custom_urlconf_module_name():
67+
resolver = RavenResolver()
68+
custom_urlconf_module = "tests.integrations.django.myapp.custom_urls"
69+
result = resolver.resolve("/foo/bar/baz/1234", custom_urlconf_module)
70+
assert result == "/foo/bar/baz/{param}"
71+
72+
73+
def test_legacy_resolver_custom_urlconf_callback():
74+
def custom_urlconf_callback():
75+
return "tests.integrations.django.myapp.custom_urls"
76+
77+
resolver = RavenResolver()
78+
result = resolver.resolve("/foo/bar/baz/1234", custom_urlconf_callback)
79+
assert result == "/foo/bar/baz/{param}"

0 commit comments

Comments
 (0)