Commit a0577415 authored by Christian Rohlfing's avatar Christian Rohlfing
Browse files

bugfixing for tests

parent fc93772e
......@@ -75,21 +75,21 @@ Options:
if inzip != "0" :
if not os.path.exists(infolder):
os.makedirs(infolder)
preparepdf.main(['--in', inzip, '--out', infolder,'--csv', csv])
preparepdf.main(['--in', inzip, '--out', infolder, '--csv', csv])
# Watermarking
watermark_outfolder = os.path.join(tmp, 'pdfs_watermarked')
if not os.path.exists(watermark_outfolder):
os.makedirs(watermark_outfolder)
watermark.main(['--in', infolder, '--out', watermark_outfolder,
watermark.main([infolder, watermark_outfolder,
'--cores', cores, '--dpi', dpi])
if sup == 1:
supoutfolder = os.path.join(tmp, 'supplements_out')
if not os.path.exists(supoutfolder):
os.makedirs(supoutfolder)
supplements.main(['--in', supinfolder, '--out', supoutfolder])
watermark.main(['--in', supoutfolder, '--out', watermark_outfolder,
'--cores', cores, '--dpi', dpi])
watermark.main([supoutfolder, watermark_outfolder,
'--cores', cores, '--dpi', dpi])
# Encryption
enc_out = os.path.join(tmp, 'pdfs_encrypted')
......@@ -97,7 +97,7 @@ Options:
os.makedirs(enc_out)
passwordcsv = os.path.join(outfolder, 'passwords.csv')
encrypt.main(['--in', watermark_outfolder, '--out', enc_out,
encrypt.main([watermark_outfolder, enc_out,
'--passwordout', passwordcsv, '--password', password])
# ZIP Archive preparation process
......@@ -105,8 +105,7 @@ Options:
moodle_tmp = os.path.join(tmp, 'tmp')
if not os.path.exists(moodle_tmp):
os.makedirs(moodle_tmp)
preparemoodle.main(['--in', enc_out, '--csv', csv, '--tmp', moodle_tmp,
'--out', moodle_out])
preparemoodle.main([enc_out, csv, moodle_out, '--tmp', moodle_tmp])
endtime = time.time()
print(f'\nTotal time taken: {endtime-starttime:.2f}s\n')
......
......@@ -147,7 +147,7 @@ def main(args):
parser.add_argument(
"infolder", help="Input folder with PDFs.")
parser.add_argument(
"-c", "--csv", default="./Bewertungen.csv",
"csv",
help="Moodle grading sheet. Default: ./Bewertungen.csv")
parser.add_argument(
"--csvdelim", default=",", help="CSV delimiter. Default: ','")
......
......@@ -19,12 +19,23 @@ class MainTest(unittest.TestCase):
def test_batch(self):
import batch
expected_files = ['moodle_feedbacks.zip', 'passwords.csv']
expected_folders = ['Four, Student_107_assignsubmission_file_']
expected_pdfs = ['123456_Nachname_w_aes.pdf']
expected_files = [
'moodle_feedbacks.zip',
'passwords.csv']
expected_folders = [
'LastnameA, FirstnameA_1519321_assignsubmission_file_',
'LastnameB, FirstnameB_1519322_assignsubmission_file_',
'LastnameJ, FirstnameJ_1519330_assignsubmission_file_',
'LastnameK, FirstnameK_1519331_assignsubmission_file_'
]
expected_pdfs = [
'123001_LastnameA_w_aes.pdf']
# Prepare parameter
in_dir = './pdfs'
in_dir = './tests/assets/pdfs'
csv = './tests/assets/Grades.csv'
dpi = 50
out_dir = os.path.join(self.test_dir, 'out')
os.mkdir(out_dir)
......@@ -35,8 +46,8 @@ class MainTest(unittest.TestCase):
os.mkdir(zipout_dir)
# Copy supplements file
batch.main(["-i", in_dir, "-o", out_dir, "-t", tmp_dir,
"--cores", "1", "--dpi", "100"])
batch.main(["-i", in_dir, "-o", out_dir, "-c", csv, "-t", tmp_dir,
"--cores", "1", "--dpi", str(dpi)])
# Assert output
created_files = os.listdir(out_dir)
......
......@@ -21,8 +21,9 @@ class MainTest(unittest.TestCase):
def test_preparemoodle_single(self):
import preparemoodle
expected_feedback_folder = 'Four, Student_107_assignsubmission_file_'
expected_feedback_file = '123456_Nachname.pdf'
expected_feedback_folder =\
'LastnameB, FirstnameB_1519322_assignsubmission_file_'
expected_feedback_file = '123002_LastnameB.pdf'
# Prepare parameter
in_dir = './tests/assets/pdfs'
......@@ -35,8 +36,8 @@ class MainTest(unittest.TestCase):
out_zip = os.path.join(self.test_dir, feedback_zip)
# Call function
preparemoodle.main([in_dir, sheet_csv,
"-t", tmp_dir, out_zip])
preparemoodle.main([in_dir, sheet_csv, out_zip,
"-t", tmp_dir])
# Unpack feedbacks
shutil.unpack_archive(out_zip, tmp_dir)
......
......@@ -24,8 +24,8 @@ class MainTest(unittest.TestCase):
'125412_T.pdf']
# Prepare parameter
in_zip = './submissions.zip'
sheet_csv = "./Bewertungen.csv"
in_zip = './tests/assets/submissions.zip'
sheet_csv = "./tests/assets/Grades.csv"
out_dir = os.path.join(self.test_dir, 'out')
os.mkdir(out_dir)
......
......@@ -19,8 +19,8 @@ class MainTest(unittest.TestCase):
import renamescans
# Prepare parameter
in_dir = './pdfs_scan'
sheet_csv = "./Bewertungen.csv"
in_dir = './tests/assets/pdfs_scan'
sheet_csv = "./tests/assets/Grades.csv"
out_dir = os.path.join(self.test_dir, 'out')
os.mkdir(out_dir)
......@@ -37,13 +37,15 @@ class MainTest(unittest.TestCase):
import renamescans
expected_files = [
'123456_F.pdf',
'123457_O.pdf',
'125412_T.pdf']
'123001_L.pdf',
'123002_L.pdf',
'123010_L.pdf',
'123011_L.pdf',
'123012_d.pdf']
# Prepare parameter
in_dir = './pdfs_scan'
sheet_csv = "./Bewertungen.csv"
in_dir = './tests/assets/pdfs_scan'
sheet_csv = "./tests/assets/Grades.csv"
out_dir = os.path.join(self.test_dir, 'out')
os.mkdir(out_dir)
......
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