Skip to content

Commit 85d9b18

Browse files
mhhd2020matthiasschaub
authored andcommitted
Add test for generate_pdf() with a too large map frame
1 parent d081d03 commit 85d9b18

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed
494 KB
Loading
667 KB
Loading

tests/unit/test_map_generation.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ def map_image(request):
5555
return Image.open(p)
5656

5757

58+
@pytest.fixture
59+
def map_image_too_big(request):
60+
"""Map image from WMS exceeding the limit on map frame size"""
61+
orientation = request.getfixturevalue("orientation")
62+
p = FIXTURE_DIR / "map-img-big-{}.jpg".format(orientation)
63+
return Image.open(p)
64+
65+
5866
@pytest.fixture
5967
def qr_code(bbox, format_, size):
6068
return generate_qr_code(
@@ -109,6 +117,25 @@ def test_generate_pdf(
109117
# )
110118

111119

120+
@pytest.mark.parametrize("orientation", ["landscape", "portrait"])
121+
def test_generate_pdf_map_frame_too_big(
122+
map_image_too_big,
123+
qr_code,
124+
orientation,
125+
) -> None:
126+
sketch_map, sketch_map_template = generate_pdf(
127+
map_image_too_big,
128+
qr_code,
129+
A0,
130+
1283.129,
131+
)
132+
133+
map_frame_img = Image.open(sketch_map_template)
134+
135+
# Check that the upper limit on map frame size is enforced
136+
assert map_frame_img.width <= 2000 and map_frame_img.height <= 2000
137+
138+
112139
def test_get_globes(format_):
113140
globes = get_globes(format_.globe_scale)
114141
for globe in globes:

0 commit comments

Comments
 (0)