File: test_normalize_query.py

package info (click to toggle)
url-normalize 2.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 268 kB
  • sloc: python: 935; makefile: 16; sh: 8
file content (24 lines) | stat: -rw-r--r-- 771 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Tests for normalize_query function."""

import pytest

from url_normalize.url_normalize import normalize_query


@pytest.mark.parametrize(
    ("query", "expected"),
    [
        ("", ""),
        ("&&&", ""),
        ("param1=val1&param2=val2", "param1=val1&param2=val2"),
        ("Ç=Ç", "%C3%87=%C3%87"),
        ("%C3%87=%C3%87", "%C3%87=%C3%87"),
        ("q=C%CC%A7", "q=%C3%87"),
        ("q=%23test", "q=%23test"),  # Preserve encoded # in value, #31
        ("where=code%3D123", "where=code%3D123"),  # Preserve encoded = in value, #25
    ],
)
def test_normalize_query_result_is_expected(query, expected):
    """Assert we got expected results from the normalize_query function."""
    result = normalize_query(query)
    assert result == expected, query