Skip to content

Commit 1eff5a2

Browse files
committed
Tests for special characters of regex nonsupported
1 parent ba68efd commit 1eff5a2

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

Diff for: tests/unit/templating/test_templating_util.py

+41-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,60 @@
1+
import pytest
2+
13
from openapi_core.templating.util import search
24

35

46
class TestSearch:
57
def test_endswith(self):
6-
path_patter = "/{test}/test"
8+
path_pattern = "/{test}/test"
79
full_url_pattern = "/test1/test/test2/test"
810

9-
result = search(path_patter, full_url_pattern)
11+
result = search(path_pattern, full_url_pattern)
1012

1113
assert result.named == {
1214
"test": "test2",
1315
}
1416

1517
def test_exact(self):
16-
path_patter = "/{test}/test"
18+
path_pattern = "/{test}/test"
1719
full_url_pattern = "/test/test"
1820

19-
result = search(path_patter, full_url_pattern)
21+
result = search(path_pattern, full_url_pattern)
2022

2123
assert result.named == {
2224
"test": "test",
2325
}
26+
27+
@pytest.mark.parametrize(
28+
"path_pattern,expected",
29+
[
30+
("/{test_id}/test", {"test_id": "test"}),
31+
("/{test.id}/test", {"test.id": "test"}),
32+
],
33+
)
34+
def test_chars_valid(self, path_pattern, expected):
35+
full_url_pattern = "/test/test"
36+
37+
result = search(path_pattern, full_url_pattern)
38+
39+
assert result.named == expected
40+
41+
@pytest.mark.xfail(
42+
reason=(
43+
"Special characters of regex not supported. "
44+
"See https://github.com/python-openapi/openapi-core/issues/672"
45+
),
46+
strict=True,
47+
)
48+
@pytest.mark.parametrize(
49+
"path_pattern,expected",
50+
[
51+
("/{test~id}/test", {"test~id": "test"}),
52+
("/{test-id}/test", {"test-id": "test"}),
53+
],
54+
)
55+
def test_special_chars_valid(self, path_pattern, expected):
56+
full_url_pattern = "/test/test"
57+
58+
result = search(path_pattern, full_url_pattern)
59+
60+
assert result.named == expected

0 commit comments

Comments
 (0)