test_preparepdf.py 1.04 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unittest
import time
import os
import tempfile


class MainTest(unittest.TestCase):
    def setUp(self):
        self.tic = time.time()  # todo this is sooo ugly

        self.test_dir = tempfile.mkdtemp()

    def tearDown(self):
        self.toc = time.time()
        t = self.toc - self.tic
        print('Time: %.3f' % (t))

    def test_copy_from_zip(self):
        import preparepdf

        expected_files = [
            '123456_F.pdf',
            '123457_O.pdf',
            '125412_T.pdf']

        # Prepare parameter
        in_zip = './submissions.zip'
        sheet_csv = "./Bewertungen.csv"

        out_dir = os.path.join(self.test_dir, 'out')
        os.mkdir(out_dir)

        tmp_dir = os.path.join(self.test_dir, 'tmp')
        os.mkdir(tmp_dir)

        # Call function
Christian Rohlfing's avatar
Christian Rohlfing committed
37
38
39
        preparepdf.main([
            "-i", in_zip, "-o", out_dir, "-c", sheet_csv,
            "-t", tmp_dir])
40
41
42
43
44

        # Assert output
        created_files = os.listdir(out_dir)
        created_files.sort()
        self.assertEqual(expected_files, created_files)