File: test_parse.py

package info (click to toggle)
mdurl 0.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 180 kB
  • sloc: python: 975; javascript: 84; sh: 8; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 742 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
25
26
import pytest

from mdurl import parse
from tests.fixtures.url import PARSED as FIXTURES


def is_url_and_dict_equal(url, url_dict):
    return (
        url.protocol == url_dict.get("protocol")
        and url.slashes == url_dict.get("slashes", False)
        and url.auth == url_dict.get("auth")
        and url.port == url_dict.get("port")
        and url.hostname == url_dict.get("hostname")
        and url.hash == url_dict.get("hash")
        and url.search == url_dict.get("search")
        and url.pathname == url_dict.get("pathname")
    )


@pytest.mark.parametrize(
    "url,expected_dict",
    FIXTURES.items(),
)
def test_parse(url, expected_dict):
    parsed = parse(url)
    assert is_url_and_dict_equal(parsed, expected_dict)