Commit 7516cb4c authored by Deb's avatar Deb
Browse files

error fixing

parent 9302746c
Identifier,"Full name","Registration number",Status,Grade,"Grade can be changed","Last modified (grade)","Feedback comments"
"Participant 1519332","d'Lastname, FirstnameL",123012,,,Yes,"Monday, 15 March 2021, 5:42 PM",
"Participant 1519331","LastnameK, FirstnameK",123011,,,Yes,"Monday, 15 March 2021, 5:42 PM",
"Participant 1519330","LastnameJ, FirstnameJ",123010,,,Yes,"Monday, 15 March 2021, 5:42 PM",
"Participant 1519322","LastnameB, FirstnameB",123002,,,Yes,"Monday, 15 March 2021, 5:42 PM",
......
......@@ -16,13 +16,13 @@ class MainTest(unittest.TestCase):
csv_file = "./tests/assets/Grades.csv"
gis = moodle_utils.extract_info(sheet_csv=csv_file)
self.assertEqual(gis[2]['lastname'], "LastnameA")
self.assertEqual(gis[2]['lastname'], "LastnameJ")
num_students = moodle_utils.get_student_number(sheet_csv=csv_file)
self.assertEqual(num_students, 3)
self.assertEqual(num_students, 5)
csv_file = "./tests/assets/Grades.csv"
gis = moodle_utils.extract_info(sheet_csv=csv_file)
# Check that "d'Lastname" gets whitened to "dLastname"
self.assertEqual(gis[3]['lastname'], "LastnameA")
self.assertEqual(gis[0]['lastname'], "dLastname")
import unittest
import time
class MainTest(unittest.TestCase):
def setUp(self):
self.tic = time.time() # todo this is sooo ugly
def tearDown(self):
self.toc = time.time()
t = self.toc - self.tic
print('Time: %.3f' % (t))
def test_extract_first_qr(self):
from utils import qr as qr_utils
expected_qr = "23-16"
pdf_file = "./tests/assets/pdfs/123001_LastnameA.pdf"
qr = qr_utils.first_qr_from_first_pdf_page(pdf_file=pdf_file)
self.assertEqual(qr, expected_qr)
def test_extract_all_qrs(self):
from utils import qr as qr_utils
expected_qrs = [
['23-01'],
['23-02'],
['23-03'],
['23-04'],
['23-05'],
['23-06'],
['23-07'],
['23-08'],
['23-09'],
['23-10'],
['23-11'],
['23-12'],
['23-13'],
['23-14'],
['23-15'],
['23-16']
]
# Parameters
dpi = 200
pdf_file = "./tests/assets/pdfs/123001_LastnameA.pdf"
# Decode all QRs
qrs, _ = qr_utils.qrs_from_pdf(pdf_file=pdf_file, dpi=dpi)
qrs.sort()
self.assertEqual(qrs, expected_qrs)
......@@ -66,25 +66,4 @@ class MainTest(unittest.TestCase):
created_files = os.listdir(out_dir)
created_files.sort()
self.assertEqual(expected_files, created_files)
def test_watermark_supplements(self):
import watermark
expected_files = ['GDET3_20H_w.pdf', 'GDET3_20H_loes_w.pdf']
in_dir = './tests/assets/supplements'
dpi = 150
tmp_dir = os.path.join(self.test_dir, 'tmp')
os.mkdir(tmp_dir)
out_dir = os.path.join(self.test_dir, 'out')
os.mkdir(out_dir)
# Watermark files
watermark.main([in_dir, out_dir,
"-t", tmp_dir, "--dpi", str(dpi)])
created_files = os.listdir(out_dir)
created_files.sort()
self.assertEqual(expected_files, created_files)
......@@ -92,7 +92,7 @@ def create_watermark_template(img_file, matnum, fontsize, dpi):
template = Image.new('RGBA', newsize, (255, 255, 255, 0))
# Font
fnt = ImageFont.truetype('./fonts/arial.ttf', round(fontsize * dpi/250))
fnt = ImageFont.truetype('./assets/fonts/arial.ttf', round(fontsize * dpi/250))
# Drawing context
d = ImageDraw.Draw(template)
......
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