def assert_link_match(
    links: link_header.LinkHeader,
    rel: str,
    path: str,
    query: Dict[str, List[str]] = None,
):
    if query is None:
        query = {}
    matching_links = links.links_by_attr_pairs([("rel", rel)])
    assert len(matching_links) == 1
    link = matching_links[0]
    href = urlparse(link.href)
    assert href.path == path
    # noinspection PyDeepBugsBinOperator
    assert query.items() <= parse_qs(href.query).items()
def assert_no_link(links: link_header.LinkHeader, rel: str):
    assert len(links.links_by_attr_pairs([("rel", rel)])) == 0