Exemplo n.º 1
0
    def test_get_view_func(self):
        f = cv.get_view_func(
                cv.VIEW_CONTENT_HEX,
                cv.VIEW_CONTENT_PRETTY_TYPE_AUTO,
                flow.ODictCaseless(),
                "foo"
              )
        assert f is cv.view_hex

        f = cv.get_view_func(
                cv.VIEW_CONTENT_RAW,
                cv.VIEW_CONTENT_PRETTY_TYPE_AUTO,
                flow.ODictCaseless(),
                "foo"
              )
        assert f is cv.view_raw

        f = cv.get_view_func(
                cv.VIEW_CONTENT_PRETTY,
                cv.VIEW_CONTENT_PRETTY_TYPE_AUTO,
                flow.ODictCaseless(
                    [["content-type", "text/html"]],
                ),
                "foo"
              )
        assert f is cv.view_xmlish

        f = cv.get_view_func(
                cv.VIEW_CONTENT_PRETTY,
                cv.VIEW_CONTENT_PRETTY_TYPE_AUTO,
                flow.ODictCaseless(
                    [["content-type", "text/flibble"]],
                ),
                "foo"
              )
        assert f is cv.view_raw

        f = cv.get_view_func(
                cv.VIEW_CONTENT_PRETTY,
                cv.VIEW_CONTENT_PRETTY_TYPE_AUTO,
                flow.ODictCaseless(
                    [["content-type", "text/flibble"]],
                ),
                "<xml></xml>"
              )
        assert f is cv.view_xmlish
    def test_get_view_func(self):
        f = cv.get_view_func(
                cv.VIEW_HEX,
                flow.ODictCaseless(),
                "foo"
              )
        assert f is cv.view_hex

        f = cv.get_view_func(
                cv.VIEW_AUTO,
                flow.ODictCaseless(),
                "foo"
              )
        assert f is cv.view_raw

        f = cv.get_view_func(
                cv.VIEW_AUTO,
                flow.ODictCaseless(
                    [["content-type", "text/html"]],
                ),
                "foo"
              )
        assert f is cv.view_html

        f = cv.get_view_func(
                cv.VIEW_AUTO,
                flow.ODictCaseless(
                    [["content-type", "text/flibble"]],
                ),
                "foo"
              )
        assert f is cv.view_raw

        f = cv.get_view_func(
                cv.VIEW_AUTO,
                flow.ODictCaseless(
                    [["content-type", "text/flibble"]],
                ),
                "<xml></xml>"
              )
        assert f is cv.view_xml