Exemplo n.º 1
0
    def test_get_content_view(self):
        r = cv.get_content_view(
            cv.get("Raw"), [["content-type", "application/json"]], "[1, 2, 3]",
            1000, lambda x: None)
        assert "Raw" in r[0]

        r = cv.get_content_view(
            cv.get("Auto"), [["content-type", "application/json"]],
            "[1, 2, 3]", 1000, lambda x: None)
        assert r[0] == "JSON"

        r = cv.get_content_view(
            cv.get("Auto"), [["content-type", "application/json"]], "[1, 2",
            1000, lambda x: None)
        assert "Raw" in r[0]

        r = cv.get_content_view(
            cv.get("AMF"), [], "[1, 2", 1000, lambda x: None)
        assert "Raw" in r[0]

        r = cv.get_content_view(
            cv.get("Auto"), [["content-type", "application/json"],
                             ["content-encoding", "gzip"]],
            encoding.encode('gzip', "[1, 2, 3]"), 1000, lambda x: None)
        assert "decoded gzip" in r[0]
        assert "JSON" in r[0]

        r = cv.get_content_view(
            cv.get("XML"), [["content-type", "application/json"],
                            ["content-encoding", "gzip"]],
            encoding.encode('gzip', "[1, 2, 3]"), 1000, lambda x: None)
        assert "decoded gzip" in r[0]
        assert "Raw" in r[0]
    def test_get_content_view(self):
        r = cv.get_content_view(cv.get("Raw"),
                                [["content-type", "application/json"]],
                                "[1, 2, 3]", 1000, lambda x: None)
        assert "Raw" in r[0]

        r = cv.get_content_view(cv.get("Auto"),
                                [["content-type", "application/json"]],
                                "[1, 2, 3]", 1000, lambda x: None)
        assert r[0] == "JSON"

        r = cv.get_content_view(cv.get("Auto"),
                                [["content-type", "application/json"]],
                                "[1, 2", 1000, lambda x: None)
        assert "Raw" in r[0]

        r = cv.get_content_view(cv.get("AMF"), [], "[1, 2", 1000,
                                lambda x: None)
        assert "Raw" in r[0]

        r = cv.get_content_view(cv.get("Auto"),
                                [["content-type", "application/json"],
                                 ["content-encoding", "gzip"]],
                                encoding.encode('gzip', "[1, 2, 3]"), 1000,
                                lambda x: None)
        assert "decoded gzip" in r[0]
        assert "JSON" in r[0]

        r = cv.get_content_view(cv.get("XML"),
                                [["content-type", "application/json"],
                                 ["content-encoding", "gzip"]],
                                encoding.encode('gzip', "[1, 2, 3]"), 1000,
                                lambda x: None)
        assert "decoded gzip" in r[0]
        assert "Raw" in r[0]
    def test_get_content_view(self):
        r = cv.get_content_view(
            cv.get("Raw"),
            Headers(content_type="application/json"),
            "[1, 2, 3]",
            1000,
            False
        )
        assert "Raw" in r[0]

        r = cv.get_content_view(
            cv.get("Auto"),
            Headers(content_type="application/json"),
            "[1, 2, 3]",
            1000,
            False
        )
        assert r[0] == "JSON"

        r = cv.get_content_view(
            cv.get("Auto"),
            Headers(content_type="application/json"),
            "[1, 2",
            1000,
            False
        )
        assert "Raw" in r[0]

        r = cv.get_content_view(
            cv.get("AMF"),
            Headers(),
            "[1, 2",
            1000,
            False
        )
        assert "Raw" in r[0]

        r = cv.get_content_view(
            cv.get("Auto"),
            Headers(
                content_type="application/json",
                content_encoding="gzip"
            ),
            encoding.encode('gzip', "[1, 2, 3]"),
            1000,
            False
        )
        assert "decoded gzip" in r[0]
        assert "JSON" in r[0]

        r = cv.get_content_view(
            cv.get("XML"),
            Headers(
                content_type="application/json",
                content_encoding="gzip"
            ),
            encoding.encode('gzip', "[1, 2, 3]"),
            1000,
            False
        )
        assert "decoded gzip" in r[0]
        assert "Raw" in r[0]