Spaces:
Running
Running
Merge pull request #255 from jlowin/template-tests
Browse files
tests/resources/test_resource_template.py
CHANGED
|
@@ -443,3 +443,20 @@ class TestMatchUriTemplate:
|
|
| 443 |
uri_template = "test://a/{x}{y}"
|
| 444 |
result = match_uri_template(uri=uri, uri_template=uri_template)
|
| 445 |
assert result is None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 443 |
uri_template = "test://a/{x}{y}"
|
| 444 |
result = match_uri_template(uri=uri, uri_template=uri_template)
|
| 445 |
assert result is None
|
| 446 |
+
|
| 447 |
+
@pytest.mark.parametrize(
|
| 448 |
+
"uri, expected_params",
|
| 449 |
+
[
|
| 450 |
+
("file://abc/xyz.py", {"path": "xyz"}),
|
| 451 |
+
("file://abc/x/y/z.py", {"path": "x/y/z"}),
|
| 452 |
+
("file://abc/x/y/z/.py", {"path": "x/y/z/"}),
|
| 453 |
+
("file://abc/x/y/z.md", None),
|
| 454 |
+
("file://x/y/z.txt", None),
|
| 455 |
+
],
|
| 456 |
+
)
|
| 457 |
+
def test_match_uri_template_with_non_slash_suffix(
|
| 458 |
+
self, uri: str, expected_params: dict[str, str]
|
| 459 |
+
):
|
| 460 |
+
uri_template = "file://abc/{path*}.py"
|
| 461 |
+
result = match_uri_template(uri=uri, uri_template=uri_template)
|
| 462 |
+
assert result == expected_params
|