Exemplo n.º 1
0
    def test_renders_camo(self, monkeypatch):
        html = "<img src=http://example.com/image.jpg>"
        monkeypatch.setattr(readme.rst, "render", lambda raw: html)

        gen_camo_url = pretend.call_recorder(
            lambda curl, ckey, url: "https://camo.example.net/image.jpg")
        monkeypatch.setattr(filters, "_camo_url", gen_camo_url)

        ctx = {
            "request":
            pretend.stub(registry=pretend.stub(settings={
                "camo.url": "https://camo.example.net/",
                "camo.key": "fake key",
            }, ), ),
        }

        result = filters.readme_renderer(ctx, "raw thing", format="rst")

        assert result == jinja2.Markup(
            "<img src=https://camo.example.net/image.jpg>")
        assert gen_camo_url.calls == [
            pretend.call(
                "https://camo.example.net/",
                "fake key",
                "http://example.com/image.jpg",
            ),
        ]
Exemplo n.º 2
0
    def test_renders_camo(self, monkeypatch):
        html = "<img src=http://example.com/image.jpg>"
        monkeypatch.setattr(readme.rst, "render", lambda raw: (html, True))

        gen_camo_url = pretend.call_recorder(
            lambda curl, ckey, url: "https://camo.example.net/image.jpg"
        )
        monkeypatch.setattr(filters, "_camo_url", gen_camo_url)

        ctx = {
            "request": pretend.stub(
                registry=pretend.stub(
                    settings={
                        "camo.url": "https://camo.example.net/",
                        "camo.key": "fake key",
                    },
                ),
            ),
        }

        result = filters.readme_renderer(ctx, "raw thing", format="rst")

        assert result == jinja2.Markup(
            "<img src=https://camo.example.net/image.jpg>"
        )
        assert gen_camo_url.calls == [
            pretend.call(
                "https://camo.example.net/",
                "fake key",
                "http://example.com/image.jpg",
            ),
        ]
Exemplo n.º 3
0
    def test_can_render(self, monkeypatch):
        monkeypatch.setattr(readme.rst, "render", lambda raw: "rendered")

        ctx = {
            "request":
            pretend.stub(registry=pretend.stub(settings={
                "camo.url": "https://camo.example.net/",
                "camo.key": "fake key",
            }, ), ),
        }

        result = filters.readme_renderer(ctx, "raw thing", format="rst")

        assert result == jinja2.Markup("rendered")
Exemplo n.º 4
0
    def test_can_render(self, monkeypatch):
        monkeypatch.setattr(readme.rst, "render", lambda raw: "rendered")

        ctx = {
            "request": pretend.stub(
                registry=pretend.stub(
                    settings={
                        "camo.url": "https://camo.example.net/",
                        "camo.key": "fake key",
                    },
                ),
            ),
        }

        result = filters.readme_renderer(ctx, "raw thing", format="rst")

        assert result == jinja2.Markup("rendered")