Exemplo n.º 1
0
    def test_get_content_view(self):
        r = cv.get_content_view(
                cv.VIEW_CONTENT_RAW,
                cv.VIEW_CONTENT_PRETTY_TYPE_AUTO,
                [["content-type", "application/json"]],
                "[1, 2, 3]"
              )
        assert r[0] == "Raw"

        r = cv.get_content_view(
                cv.VIEW_CONTENT_PRETTY,
                cv.VIEW_CONTENT_PRETTY_TYPE_AUTO,
                [["content-type", "application/json"]],
                "[1, 2, 3]"
              )
        assert r[0] == "JSON"


        r = cv.get_content_view(
                cv.VIEW_CONTENT_PRETTY,
                cv.VIEW_CONTENT_PRETTY_TYPE_AUTO,
                [["content-type", "application/json"]],
                "[1, 2"
              )
        assert r[0] == "Raw"

        r = cv.get_content_view(
                cv.VIEW_CONTENT_PRETTY,
                cv.VIEW_CONTENT_PRETTY_TYPE_AUTO,
                [
                    ["content-type", "application/json"],
                    ["content-encoding", "gzip"]
                ],
                encoding.encode('gzip', "[1, 2, 3]")
              )
        assert "decoded gzip" in r[0]
        assert "JSON" in r[0]


        r = cv.get_content_view(
                cv.VIEW_CONTENT_PRETTY,
                cv.VIEW_CONTENT_PRETTY_TYPE_XML,
                [
                    ["content-type", "application/json"],
                    ["content-encoding", "gzip"]
                ],
                encoding.encode('gzip', "[1, 2, 3]")
              )
        assert "decoded gzip" in r[0]
        assert "forced" in r[0]
    def test_get_content_view(self):
        r = cv.get_content_view(
                cv.VIEW_RAW,
                [["content-type", "application/json"]],
                "[1, 2, 3]",
                1000
              )
        assert "Raw" in r[0]

        r = cv.get_content_view(
                cv.VIEW_AUTO,
                [["content-type", "application/json"]],
                "[1, 2, 3]",
                1000
              )
        assert r[0] == "JSON"

        r = cv.get_content_view(
                cv.VIEW_AUTO,
                [["content-type", "application/json"]],
                "[1, 2",
                1000
              )
        assert "Raw" in r[0]

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

        r = cv.get_content_view(
                cv.VIEW_XML,
                [
                    ["content-type", "application/json"],
                    ["content-encoding", "gzip"]
                ],
                encoding.encode('gzip', "[1, 2, 3]"),
                1000
              )
        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]
Exemplo n.º 4
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]