-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_utils.py
37 lines (31 loc) · 1.12 KB
/
test_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Tests for OpenAPI spec handling."""
import pytest
from utils import parse_query_string
from stac_auth_proxy.utils.requests import extract_variables
@pytest.mark.parametrize(
"url, expected",
(
("/collections/123", {"collection_id": "123"}),
("/collections/123/items", {"collection_id": "123"}),
("/collections/123/bulk_items", {"collection_id": "123"}),
("/collections/123/items/456", {"collection_id": "123", "item_id": "456"}),
("/collections/123/bulk_items/456", {"collection_id": "123", "item_id": "456"}),
("/other/123", {}),
),
)
def test_extract_variables(url, expected):
"""Test extracting variables from a URL path."""
assert extract_variables(url) == expected
@pytest.mark.parametrize(
"query, expected",
(
("foo=bar", {"foo": "bar"}),
(
'filter={"xyz":"abc"}&filter-lang=cql2-json',
{"filter": {"xyz": "abc"}, "filter-lang": "cql2-json"},
),
),
)
def test_parse_query_string(query, expected):
"""Validate test helper for parsing query strings."""
assert parse_query_string(query) == expected