22
22
example_url_conf = (
23
23
url (r"^api/(?P<project_id>[\w_-]+)/store/$" , lambda x : "" ),
24
24
url (r"^api/(?P<version>(v1|v2))/author/$" , lambda x : "" ),
25
+ url (
26
+ r"^api/(?P<project_id>[^\/]+)/product/(?P<pid>(?:\d+|[A-Fa-f0-9-]{32,36}))/$" ,
27
+ lambda x : "" ,
28
+ ),
25
29
url (r"^report/" , lambda x : "" ),
26
30
url (r"^example/" , include (included_url_conf )),
27
- url (
28
- r"^(?P<slug>[$\\-_.+!*(),\\w//]+)/$" , lambda x : ""
29
- ), # example of complex regex from django-cms
30
31
)
31
32
32
33
@@ -56,14 +57,12 @@ def test_legacy_resolver_included_match():
56
57
assert result == "/example/foo/bar/{param}"
57
58
58
59
59
- def test_complex_regex_from_django_cms ():
60
- """
61
- Reference: https://github.com/getsentry/sentry-python/issues/1527
62
- """
63
-
60
+ def test_capture_multiple_named_groups ():
64
61
resolver = RavenResolver ()
65
- result = resolver .resolve ("/,/" , example_url_conf )
66
- assert result == "/{slug}/"
62
+ result = resolver .resolve (
63
+ "/api/myproject/product/cb4ef1caf3554c34ae134f3c1b3d605f/" , example_url_conf
64
+ )
65
+ assert result == "/api/{project_id}/product/{pid}/"
67
66
68
67
69
68
@pytest .mark .skipif (django .VERSION < (2 , 0 ), reason = "Requires Django > 2.0" )
@@ -74,3 +73,13 @@ def test_legacy_resolver_newstyle_django20_urlconf():
74
73
resolver = RavenResolver ()
75
74
result = resolver .resolve ("/api/v2/1234/store/" , url_conf )
76
75
assert result == "/api/v2/{project_id}/store/"
76
+
77
+
78
+ @pytest .mark .skipif (django .VERSION < (2 , 0 ), reason = "Requires Django > 2.0" )
79
+ def test_legacy_resolver_newstyle_django20_urlconf_multiple_groups ():
80
+ from django .urls import path
81
+
82
+ url_conf = (path ("api/v2/<int:project_id>/product/<int:pid>" , lambda x : "" ),)
83
+ resolver = RavenResolver ()
84
+ result = resolver .resolve ("/api/v2/1234/product/5689" , url_conf )
85
+ assert result == "/api/v2/{project_id}/product/{pid}"
0 commit comments