File: test_helper.py

package info (click to toggle)
python-picnic-api2 1.3.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 224 kB
  • sloc: python: 670; makefile: 3
file content (35 lines) | stat: -rw-r--r-- 1,160 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests

from python_picnic_api2.helper import get_image, get_recipe_image


def test_get_image():
    id = "8560e1f1c2d2811dfefbbb2342ef0d95250533f2131416aca459bde35d73e901"
    size = "tile-medium"
    suffix = "webp"
    url = get_image(id, size=size, suffix=suffix)

    response = requests.get(url)

    # Check if the response status code indicates success
    assert response.status_code == 200, "Failed to fetch URL"

    # Check if the response content type is an image format
    content_type = response.headers.get("content-type")
    assert content_type.startswith("image/"), "URL does not return an image"


def test_get_recipe_image():
    id = "5c4cc7cb7a0429695da708394eb0cae1bd9b92935ac76c8fda63bbc57ad5b826"
    size = "medium"
    url = get_recipe_image(id, size=size)
    print(url)

    response = requests.get(url)

    # Check if the response status code indicates success
    assert response.status_code == 200, "Failed to fetch URL"

    # Check if the response content type is an image format
    content_type = response.headers.get("content-type")
    assert content_type.startswith("image/"), "URL does not return an image"