Cache for reading annotation
This commit is contained in:
1 parent
55d5cf16c9
commit
ff7496b113
12 files changed
+466
-13
No files matched your search
@@ -9,9 +9,31 @@ import pandas as pd
|
||||
from PIL import Image
|
||||
|
||||
from copienator.commands import add_final_score
|
||||
from copienator import atomic_write_json, read_json
|
||||
|
||||
|
||||
class AddFinalScoreTests(unittest.TestCase):
|
||||
def test_statistics_average_all_score_files_and_round_up_without_float_drift(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
root = Path(temporary)
|
||||
returns = root / 'A Rendre'
|
||||
atomic_write_json(returns / 'Alice/score.json', {
|
||||
'Ex 1': '2.0', 'Ex 2': '0.1', 'Ex 3': '', 'Empty': '', 'Zero': 0,
|
||||
})
|
||||
atomic_write_json(returns / 'Bob/score.json', {
|
||||
'Ex 1': 2.01, 'Ex 2': '0.1', 'Ex 3': '3.5', 'Empty': None,
|
||||
})
|
||||
output = root / 'output'
|
||||
output.mkdir()
|
||||
add_final_score.write_score_statistics(returns, output)
|
||||
self.assertEqual(read_json(output / 'stat.json'), {
|
||||
'Ex 1': '2.1', 'Ex 2': '0.1', 'Ex 3': '3.5', 'Empty': '', 'Zero': '0.0',
|
||||
})
|
||||
# Rebuilding uses current returns, without accumulating old averages.
|
||||
atomic_write_json(returns / 'Bob/score.json', {'Ex 1': 4})
|
||||
add_final_score.write_score_statistics(returns, output)
|
||||
self.assertEqual(read_json(output / 'stat.json')['Ex 1'], '3.0')
|
||||
|
||||
def test_merged_histogram_is_copied_only_when_selected(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
root = Path(temporary)
|
||||
@@ -80,6 +102,7 @@ class AddFinalScoreTests(unittest.TestCase):
|
||||
self.assertFalse((output / "Student.pdf").exists())
|
||||
self.assertFalse((student / "answers" / "001 - Ex 1.jpg").exists())
|
||||
self.assertEqual((output / "histogramme.pdf").read_bytes(), b"histogram")
|
||||
self.assertEqual(read_json(output / "stat.json"), {"Ex 1": "4.0"})
|
||||
|
||||
def test_omits_answers_directory_when_it_was_not_generated(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
|
||||
Reference in new issue
Block a user