Skip to content

Commit 7d861da

Browse files
committed
Add tests for total_score config
1 parent 6e396fb commit 7d861da

File tree

9 files changed

+738
-0
lines changed

9 files changed

+738
-0
lines changed

tests/commands/verify/test_integration.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,38 @@ def test_no_gen_parameters(capsys, create_package):
174174
run(["--no-ingen"])
175175
assert os.path.exists(os.path.join(create_package, "in", "abc2a.in"))
176176
assert os.path.exists(os.path.join(create_package, "out", "abc2a.out"))
177+
178+
@pytest.mark.parametrize("create_package", [util.get_score_package()], indirect=True)
179+
def test_total_score_in_config(capsys, create_package):
180+
"""
181+
Test if total_score overwrites default 100 for verification if contest type is OIJ.
182+
"""
183+
run(["-Ttime"])
184+
185+
if os.path.exists(paths.get_cache_path()):
186+
shutil.rmtree(paths.get_cache_path())
187+
cache.create_cache_dirs()
188+
config = package_util.get_config()
189+
config["total_score"] = 25
190+
sm_util.save_config(config)
191+
with pytest.raises(SystemExit) as e:
192+
run(["-Ttime"])
193+
assert e.value.code == 1
194+
out = capsys.readouterr().out
195+
assert "Total score in config is 40, but should be 25." in out
196+
197+
198+
@pytest.mark.parametrize("create_package", [util.get_score_package()], indirect=True)
199+
def test_total_score_in_config_oi(capsys, create_package):
200+
"""
201+
Test if total_score does not overwrite default 100 for verification if contest type is OI.
202+
"""
203+
config = package_util.get_config()
204+
config["sinol_contest_type"] = "oi"
205+
sm_util.save_config(config)
206+
with pytest.raises(SystemExit) as e:
207+
run(["-Ttime"])
208+
assert e.value.code == 1
209+
out = capsys.readouterr().out
210+
print(out)
211+
assert "Total score in config is 40, but should be 100." in out

tests/packages/score/config.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
title: Package for testing total_score configuration
2+
sinol_task_id: score
3+
sinol_contest_type: oij
4+
memory_limit: 16000
5+
time_limit: 1000
6+
total_score: 40
7+
scores:
8+
1: 10
9+
2: 10
10+
3: 10
11+
4: 10
12+
sinol_expected_scores:
13+
score.cpp:
14+
expected:
15+
1: {points: 10, status: OK}
16+
2: {points: 10, status: OK}
17+
3: {points: 10, status: OK}
18+
4: {points: 10, status: OK}
19+
points: 40

tests/packages/score/doc/.gitkeep

Whitespace-only changes.

tests/packages/score/in/.gitkeep

Whitespace-only changes.

tests/packages/score/out/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)