Improve web finalisation navigation, caching and Anot support
This commit is contained in:
1 parent
5de70dbc0d
commit
b069805988
21 files changed
+339
-58
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
import pandas as pd
|
||||
from copienator import atomic_write_json
|
||||
from copienator.final_scores import exported_scores
|
||||
|
||||
|
||||
class ExportedFinalScoresTests(unittest.TestCase):
|
||||
def test_legacy_export_uses_only_sheet_predating_export(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
root = Path(temporary)/'Interro'
|
||||
(root/'A Rendre/Alice (01)').mkdir(parents=True)
|
||||
ods = root/'marks.ods'
|
||||
ods.write_bytes(b'sheet')
|
||||
image = root/'output/Interro/Alice/Alice.jpg'
|
||||
image.parent.mkdir(parents=True)
|
||||
image.write_bytes(b'export')
|
||||
os.utime(ods, ns=(1000000,1000000))
|
||||
os.utime(image, ns=(2000000,2000000))
|
||||
with patch('copienator.final_scores.configuration.FINAL_SCORE_OUTPUT_DIR',root/'output'), \
|
||||
patch('copienator.final_scores.configuration.FINAL_SCORE_ODS_PATH',ods), \
|
||||
patch('pandas.read_excel',return_value=pd.DataFrame({0:['Alice'],1:[12.39]})) as read:
|
||||
self.assertEqual(exported_scores(root,root), {'1':'12.3'})
|
||||
os.utime(ods, ns=(3000000,3000000))
|
||||
read.reset_mock()
|
||||
self.assertEqual(exported_scores(root,root), {})
|
||||
read.assert_not_called()
|
||||
|
||||
def test_no_final_mark_before_export_and_saved_marks_do_not_read_live_sheet(self):
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
root=Path(temporary)
|
||||
with patch('copienator.final_scores.configuration.FINAL_SCORE_OUTPUT_DIR',root/'output'), \
|
||||
patch('copienator.final_scores.configuration.FINAL_SCORE_ODS_PATH',root/'missing.ods'), \
|
||||
patch('pandas.read_excel') as read:
|
||||
self.assertEqual(exported_scores(root,root), {})
|
||||
atomic_write_json(root/'.copienator/final_scores.json',
|
||||
{'version':1,'copies':{'01':{'score':'0.0','name':'Alice'}}})
|
||||
self.assertEqual(exported_scores(root,root), {'1':'0.0'})
|
||||
read.assert_not_called()
|
||||
Reference in new issue
Block a user