Skip to content

Commit

Permalink
Tests for special characters of regex nonsupported
Browse files Browse the repository at this point in the history
  • Loading branch information
p1c2u committed Sep 25, 2023
1 parent ba68efd commit 1eff5a2
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions tests/unit/templating/test_templating_util.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,60 @@
import pytest

from openapi_core.templating.util import search


class TestSearch:
def test_endswith(self):
path_patter = "/{test}/test"
path_pattern = "/{test}/test"
full_url_pattern = "/test1/test/test2/test"

result = search(path_patter, full_url_pattern)
result = search(path_pattern, full_url_pattern)

assert result.named == {
"test": "test2",
}

def test_exact(self):
path_patter = "/{test}/test"
path_pattern = "/{test}/test"
full_url_pattern = "/test/test"

result = search(path_patter, full_url_pattern)
result = search(path_pattern, full_url_pattern)

assert result.named == {
"test": "test",
}

@pytest.mark.parametrize(
"path_pattern,expected",
[
("/{test_id}/test", {"test_id": "test"}),
("/{test.id}/test", {"test.id": "test"}),
],
)
def test_chars_valid(self, path_pattern, expected):
full_url_pattern = "/test/test"

result = search(path_pattern, full_url_pattern)

assert result.named == expected

@pytest.mark.xfail(
reason=(
"Special characters of regex not supported. "
"See https://github.com/python-openapi/openapi-core/issues/672"
),
strict=True,
)
@pytest.mark.parametrize(
"path_pattern,expected",
[
("/{test~id}/test", {"test~id": "test"}),
("/{test-id}/test", {"test-id": "test"}),
],
)
def test_special_chars_valid(self, path_pattern, expected):

This comment has been minimized.

Copy link
@p1c2u

p1c2u Sep 25, 2023

Author Collaborator

Relates to #672

full_url_pattern = "/test/test"

result = search(path_pattern, full_url_pattern)

assert result.named == expected

0 comments on commit 1eff5a2

Please sign in to comment.