def METHOD_NAME():
    @pytest.mark.parametrize("as_json", [True, False])
    def it_returns_an_image_url(expect, client, as_json):
        data = {"text_lines[]": ["foo", "bar"], "extension": "jpg"}
        kwargs: dict = {"content": json.dumps(data)} if as_json else {"data": data}
        request, response = client.post("/templates/iw", **kwargs)
        expect(response.status) == 201
        expect(response.json) == {
            "url": "http://localhost:5000/images/iw/foo/bar.jpg"
        }
    @pytest.mark.parametrize("as_json", [True, False])
    def it_supports_custom_backgrounds(expect, client, as_json):
        data = {
            "background": "https://www.gstatic.com/webp/gallery/3.png",
            "text_lines[]": ["foo", "bar"],
            "extension": "jpg",
        }
        kwargs: dict = {"content": json.dumps(data)} if as_json else {"data": data}
        request, response = client.post("/templates/custom", **kwargs)
        expect(response.status) == 201
        expect(response.json) == {
            "url": "http://localhost:5000/images/custom/foo/bar.jpg"
            "?background=https://www.gstatic.com/webp/gallery/3.png"
        }
    def it_accepts_template_id_as_custom_background(expect, client):
        data = {
            "background": "fry",
            "text_lines[]": ["foo", "bar"],
            "extension": "jpg",
        }
        request, response = client.post("/templates/custom", data=data)
        expect(response.status) == 201
        expect(response.json) == {
            "url": "http://localhost:5000/images/fry/foo/bar.jpg"
        }
    @pytest.mark.parametrize("id", ["iw", "custom"])
    def it_redirects_if_requested(expect, client, id):
        data = {"text_lines": ["abc"], "redirect": True}
        request, response = client.post(
            f"/templates/{id}", data=data, allow_redirects=False
        )
        redirect = f"http://localhost:5000/images/{id}/abc.png?status=201"
        expect(response.status) == 302
        expect(response.headers["Location"]) == redirect
    def it_handles_unknown_template_id(expect, client, unknown_template):
        data = {"text_lines": ["one", "two"]}
        request, response = client.post(
            f"/templates/{unknown_template.id}", data=data
        )
        expect(response.status) == 404
        expect(response.json) == {
            "url": "http://localhost:5000/images/unknown/one/two.png"
        }