Skip to content

Commit 768f951

Browse files
committed
[test][export] Add assertions for which PDFs should be in the ZIPs
1 parent 646fcb1 commit 768f951

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

test/test_problems.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ def test_samplezip(self):
160160
zip_path.unlink()
161161

162162
def test_zip(self):
163-
tools.test(["zip", "--force"])
164163
zip_path = Path("identity.zip")
165164

165+
tools.test(["zip", "--force"])
166+
166167
# The full zip should contain the samples with the original file extensions.
167168
assert sorted(
168169
(info.filename, info.file_size)
@@ -178,6 +179,25 @@ def test_zip(self):
178179
*((f"identity/data/sample/6.{ext}.statement", 2) for ext in ["ans", "in"]),
179180
], "Zip contents for data/sample/ are not correct"
180181

182+
# The full zip should contain all PDFs in their corresponding directories.
183+
assert sorted(
184+
info.filename for info in ZipFile(zip_path).infolist() if info.filename.endswith(".pdf")
185+
) == [
186+
f"identity/{path}.{lang}.pdf"
187+
for path in ["problem_slide/problem-slide", "solution/solution", "statement/problem"]
188+
for lang in ["de", "en"]
189+
], "Zip contents for PDFs with both languages are not correct"
190+
191+
tools.test(["zip", "--force", "--lang", "en"])
192+
193+
# The full zip should contain all PDFs in their corresponding directories.
194+
assert sorted(
195+
info.filename for info in ZipFile(zip_path).infolist() if info.filename.endswith(".pdf")
196+
) == [
197+
f"identity/{path}.en.pdf"
198+
for path in ["problem_slide/problem-slide", "solution/solution", "statement/problem"]
199+
], "Zip contents for PDFs with `--lang en` are not correct"
200+
181201
zip_path.unlink()
182202

183203
# Misc
@@ -234,6 +254,32 @@ def test_problem_slides(self):
234254
def test_gitlabci(self):
235255
tools.test(["gitlabci"])
236256

257+
def test_zip(self):
258+
zip_path = Path("problems.zip")
259+
260+
for languages in [["en", "de"], ["en"]]:
261+
tools.test(["zip", "--force", "--lang", *languages])
262+
263+
# The full zip should contain all PDFs in their corresponding directories.
264+
assert sorted(info.filename for info in ZipFile(zip_path).infolist()) == sorted(
265+
[
266+
"contest.yaml",
267+
"identity.zip",
268+
"problems.yaml",
269+
"samples.zip",
270+
*(
271+
f"{name}{suffix}.{lang}.pdf"
272+
for name in ["contest", "solutions", "problem-slides"]
273+
for lang in languages
274+
for suffix in ["", "-web"]
275+
# The problem slides do not have a -web version.
276+
if (name, suffix) != ("problem-slides", "-web")
277+
),
278+
]
279+
), f"Zip contents for contest zip are not correct for languages {languages}"
280+
281+
zip_path.unlink()
282+
237283

238284
@pytest.fixture(scope="function")
239285
def tmp_contest_dir(tmp_path):

0 commit comments

Comments
 (0)