refactor page processing

Separate out saving the file, updating the database, and identifying the
student number.  The last one is implemented such that it can be called outside
of the scanning process (i.e. it only relies on the information that's in the database).
parent 82c77b54
......@@ -22,18 +22,10 @@ def mock_get_box_return_original(monkeypatch, datadir):
# More test data should be added. If done, maybe also consider increasing
# the threshold in the assert.
def test_get_studentnumber_precision(datadir, mock_get_box_return_original):
class MockExamConfig:
student_id_widget_area = [
0,
0,
0,
0,
]
im_names = os.listdir(os.path.join(datadir, 'studentnumbers'))
for filename_full in im_names:
im_path = os.path.join(datadir, 'studentnumbers', f'{filename_full}')
filename_short, _ = os.path.splitext(filename_full)
expected_number = int(filename_short)
detected_number = scans.get_student_number(im_path, MockExamConfig)
detected_number = scans.get_student_number(im_path, [0, 0, 0, 0])
assert(expected_number == detected_number)
......@@ -28,9 +28,7 @@ def test_decode_barcode(datadir, image_filename, token, expected, mock_get_box_r
exam_config = ExamMetadata(
token=token,
barcode_area=[0],
student_id_widget_area=None,
problem_ids=None
barcode_coords=[0],
)
image = np.array(Image.open(image_path))
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment