Coverage for api/examples/image_responses.py: 100%
12 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 06:14 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 06:14 +0000
1from api.examples.environment import ORIGIN
4identifier = "4bc43a04-ef46-4544-a0c1-63c63f56e276"
6base_image = {
7 "id": identifier,
8 "title": "Tree Bark Photo",
9 "indexed_on": "2022-08-27T17:39:48Z",
10 "foreign_landing_url": "https://stocksnap.io/photo/XNVBVXO3B7",
11 "url": "https://cdn.stocksnap.io/img-thumbs/960w/XNVBVXO3B7.jpg",
12 "creator": "Tim Sullivan",
13 "creator_url": "https://www.secretagencygroup.com",
14 "license": "cc0",
15 "license_version": "1.0",
16 "license_url": "https://creativecommons.org/publicdomain/zero/1.0/",
17 "provider": "stocksnap",
18 "source": "stocksnap",
19 "category": "photograph",
20 "filesize": 896128,
21 "filetype": "jpg",
22 "tags": [
23 {"accuracy": None, "name": "tree", "unstable__provider": "stocksnap"},
24 {"accuracy": None, "name": "bark", "unstable__provider": "stocksnap"},
25 {"accuracy": None, "name": "texture", "unstable__provider": "stocksnap"},
26 {"accuracy": None, "name": "wood", "unstable__provider": "stocksnap"},
27 {"accuracy": None, "name": "nature", "unstable__provider": "stocksnap"},
28 {"accuracy": None, "name": "pattern", "unstable__provider": "stocksnap"},
29 {"accuracy": None, "name": "rough", "unstable__provider": "stocksnap"},
30 {"accuracy": None, "name": "surface", "unstable__provider": "stocksnap"},
31 {"accuracy": None, "name": "brown", "unstable__provider": "stocksnap"},
32 {"accuracy": None, "name": "old", "unstable__provider": "stocksnap"},
33 {"accuracy": None, "name": "background", "unstable__provider": "stocksnap"},
34 {"accuracy": None, "name": "trunk", "unstable__provider": "stocksnap"},
35 {"accuracy": None, "name": "natural", "unstable__provider": "stocksnap"},
36 {"accuracy": None, "name": "forest", "unstable__provider": "stocksnap"},
37 {"accuracy": None, "name": "detail", "unstable__provider": "stocksnap"},
38 {"accuracy": None, "name": "lumber", "unstable__provider": "stocksnap"},
39 {"accuracy": None, "name": "weathered", "unstable__provider": "stocksnap"},
40 {"accuracy": None, "name": "timber", "unstable__provider": "stocksnap"},
41 {"accuracy": None, "name": "stump", "unstable__provider": "stocksnap"},
42 {"accuracy": None, "name": "closeup", "unstable__provider": "stocksnap"},
43 {"accuracy": None, "name": "root", "unstable__provider": "stocksnap"},
44 {"accuracy": 0.95, "name": "tree", "unstable__provider": "machine_example"},
45 {"accuracy": 0.9, "name": "bark", "unstable__provider": "machine_example"},
46 {"accuracy": 0.98, "name": "plant", "unstable__provider": "machine_example"},
47 ],
48 "attribution": (
49 '"Tree Bark Photo" by Tim Sullivan is marked with '
50 "CC0 1.0. To view the terms, visit "
51 "https://creativecommons.org/publicdomain/zero/1.0/."
52 ),
53 "fields_matched": [],
54 "mature": False,
55 "height": 4016,
56 "width": 6016,
57 "thumbnail": f"{ORIGIN}/v1/images/{identifier}/thumb/",
58 "detail_url": f"{ORIGIN}/v1/images/{identifier}/",
59 "related_url": f"{ORIGIN}/v1/images/{identifier}/related/",
60 "unstable__sensitivity": [],
61}
63image_search_200_example = {
64 "result_count": 1,
65 "page_count": 1,
66 "page_size": 20,
67 "page": 1,
68 "results": [base_image | {"fields_matched": ["title"]}],
69}
71image_search_400_example = {
72 "error": "InputError",
73 "detail": "Invalid input given for fields. 'license' -> License 'PDMNBCG' does not exist.", # noqa: E501
74 "fields": ["license"],
75}
77image_stats_200_example = [
78 {
79 "source_name": "flickr",
80 "display_name": "Flickr",
81 "source_url": "https://www.flickr.com",
82 "logo_url": None,
83 "media_count": 2500,
84 },
85 {
86 "source_name": "stocksnap",
87 "display_name": "StockSnap",
88 "source_url": "https://stocksnap.io",
89 "logo_url": None,
90 "media_count": 2500,
91 },
92]
94image_detail_200_example = base_image
96image_detail_404_example = {"detail": "Not found."}
98image_related_200_example = {
99 "result_count": 1,
100 "page_count": 1,
101 "page_size": 20,
102 "page": 1,
103 "results": [
104 {
105 "title": "exam tactics",
106 "id": "610756ec-ae31-4d5e-8f03-8cc52f31b71d",
107 "creator": "Sean MacEntee",
108 "creator_url": "https://www.flickr.com/photos/18090920@N07",
109 "tags": [{"name": "exam"}, {"name": "tactics"}],
110 "url": "https://live.staticflickr.com/4065/4459771899_07595dc42e.jpg", # noqa: E501
111 "thumbnail": f"{ORIGIN}/v1/thumbs/610756ec-ae31-4d5e-8f03-8cc52f31b71d", # noqa: E501
112 "provider": "flickr",
113 "source": "flickr",
114 "license": "by",
115 "license_version": "2.0",
116 "license_url": "https://creativecommons.org/licenses/by/2.0/",
117 "foreign_landing_url": "https://www.flickr.com/photos/18090920@N07/4459771899", # noqa: E501
118 "detail_url": f"{ORIGIN}/v1/images/610756ec-ae31-4d5e-8f03-8cc52f31b71d", # noqa: E501
119 "related_url": f"{ORIGIN}/v1/recommendations/images/610756ec-ae31-4d5e-8f03-8cc52f31b71d", # noqa: E501
120 }
121 ],
122}
124image_oembed_200_example = {
125 "version": "1.0",
126 "type": "photo",
127 "width": 6016,
128 "height": 4016,
129 "title": "Tree Bark Photo",
130 "author_name": "Tim Sullivan",
131 "author_url": "https://www.secretagencygroup.com",
132 "license_url": "https://creativecommons.org/publicdomain/zero/1.0/",
133}
135image_oembed_400_example = {"detail": {"url": ["Could not parse identifier from URL."]}}
137image_complain_201_example = {
138 "identifier": identifier,
139 "reason": "mature",
140 "description": "Image contains sensitive content",
141}