# Path: tests/conftest.py
# def assert_cache_control(headers, cache_parts):
#     """Assert that all parts of the Cache-Control header are present."""
#     assert dict(headers) == Any.dict.containing({"Cache-Control": Any.string()})
#     assert (
#         headers["Cache-Control"].split(", ") == Any.list.containing(cache_parts).only()
#     )


from urllib.parse import quote_plus
from h_matchers import Any
from tests.conftest import assert_cache_control
import httpretty
import pytest




class TestRouteByContent:
    DEFAULT_OPTIONS = {
        "via.client.ignoreOtherConfiguration": "1",
        "via.client.openSidebar": "1",
        "via.external_link_mode": "new-tab",
    }

    @pytest.mark.usefixtures("html_response", "checkmate_pass")
    def test_proxy_html(self, test_app):
        target_url = "http://example.com"

        response = test_app.get(f"/route?url={target_url}")

        assert response.status_code == 302
        query = dict(self.DEFAULT_OPTIONS)
        assert response.location == Any.url.matching(
            f"https://viahtml.hypothes.is/proxy/{target_url}/"
        ).with_query(query)

    @pytest.mark.usefixtures("pdf_response", "checkmate_pass")
    def test_proxy_pdf(self, test_app):
        target_url = "http://example.com"

        response = test_app.get(f"/route?url={target_url}")

        assert response.status_code == 302

# Path: tests/conftest.py
# def assert_cache_control(headers, cache_parts):
#     """Assert that all parts of the Cache-Control header are present."""
#     assert dict(headers) == Any.dict.containing({"Cache-Control": Any.string()})
#     assert (
#         headers["Cache-Control"].split(", ") == Any.list.containing(cache_parts).only()
#     )


# Path: tests/functional/api/views/route_by_content_test.py
from urllib.parse import quote_plus
from h_matchers import Any
from tests.conftest import assert_cache_control
import httpretty
import pytest





class TestRouteByContent:
    DEFAULT_OPTIONS = {
        "via.client.ignoreOtherConfiguration": "1",
        "via.client.openSidebar": "1",
        "via.external_link_mode": "new-tab",
    }

    @pytest.mark.usefixtures("html_response", "checkmate_pass")
    def test_proxy_html(self, test_app):
        target_url = "http://example.com"

        response = test_app.get(f"/route?url={target_url}")

        assert response.status_code == 302
        query = dict(self.DEFAULT_OPTIONS)
        assert response.location == Any.url.matching(
            f"https://viahtml.hypothes.is/proxy/{target_url}/"
        ).with_query(query)

    @pytest.mark.usefixtures("pdf_response", "checkmate_pass")
    def test_proxy_pdf(self, test_app):
        target_url = "http://example.com"

        response = test_app.get(f"/route?url={target_url}")

        assert response.status_code == 302

        query = dict(self.DEFAULT_OPTIONS)