예제 #1
0
    def test_with_fragment_specified(self):
        matcher = AnyURL.with_fragment("fragment")

        assert matcher == "#fragment"
        assert matcher == "http://example.com#fragment"
        assert matcher != "#different"
        assert matcher != "http://example.com"
예제 #2
0
    def test_with_fragment_required(self):
        matcher = AnyURL.with_fragment()

        assert matcher == "#fragment"
        assert matcher == "http://example.com#fragment"
        assert matcher == "#different"
        assert matcher != "http://example.com"
예제 #3
0
    def test_containing_query(self):
        matcher = AnyURL.containing_query({"a": "b"})

        assert matcher == "?a=b"
        assert matcher == "?a=b&a=c"
        assert matcher == "?a=c&a=b"

        assert matcher != ""
        assert matcher != "?e=f"
예제 #4
0
    def test_all_methods_together(self):
        base_url = "http://example.com/path?a=b#fragment"
        matcher = (AnyURL.matching(base_url).with_host(
            "www.example.com").with_path("/different").with_query({
                "b": "a"
            }).with_fragment("new_fragment"))

        assert matcher != base_url
        assert matcher == "http://www.example.com/different?b=a#new_fragment"

        matcher = matcher.with_scheme("ftp").containing_query({"c": "d"})

        assert matcher == "ftp://www.example.com/different?b=a&c=d#new_fragment"
예제 #5
0
    def test_with_query_specified(self):
        matcher = AnyURL.with_query({"a": "b"})

        assert matcher == "?a=b"
        assert matcher != "?a=b&a=c"
        assert matcher != ""
예제 #6
0
    def test_with_query_required(self):
        matcher = AnyURL.with_query()

        assert matcher == "?a=b"
        assert matcher != ""
예제 #7
0
    def test_with_params_specified(self):
        matcher = AnyURL.with_params("params")

        assert matcher == "http://www.example.com/path;params"
        assert matcher != "http://www.example.com/path;different"
예제 #8
0
    def test_with_params_required(self):
        matcher = AnyURL.with_params()

        assert matcher == "http://example.com/path;params"
        assert matcher != "http://example.com/path"
예제 #9
0
    def test_with_path_specified(self):
        matcher = AnyURL.with_path("path")

        assert matcher == "http://example.com/path"
        assert matcher != "http://example.com/different_path"
        assert matcher != "http://example.com/"
예제 #10
0
    def test_with_path_required(self):
        matcher = AnyURL.with_path()

        assert matcher == "/path"
        assert matcher != "http://example.com"
예제 #11
0
    def test_with_host_specified(self):
        matcher = AnyURL.with_host("www.example.com")

        assert matcher == "http://www.example.com"
        assert matcher != "http://ftp.example.com"
예제 #12
0
    def test_with_host_required(self):
        matcher = AnyURL.with_host()

        assert matcher == "www.example.com"
        assert matcher != "http://"
예제 #13
0
 def test_with_scheme_specified(self):
     matcher = AnyURL.with_scheme("http")
     assert matcher == "http://"
     assert matcher != "https://"
예제 #14
0
    def test_matching_base_url(self):
        url = "http://example.com"
        matcher = AnyURL.matching(url)

        assert matcher == url
        assert matcher != (url + "?a=b")