-
Notifications
You must be signed in to change notification settings - Fork 2
/
spreadsheet_badge_printer_test.py
64 lines (51 loc) · 2.8 KB
/
spreadsheet_badge_printer_test.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: latin-1 -*-
import unittest
from spreadsheet_badge_printer import BadgePrinter
from spreadsheet_badge_printer import SpreadsheetFetcher
from spreadsheet_badge_printer import Registrant
class BadgePrinterTest(unittest.TestCase):
def testRendersUnicodeIntoPdfFromListOfNames(self):
registrants = [ Registrant('time', u'Jo\xf1\xf1\xf3n Andrew Unicode', 'jwolter', 'US-MTV',
'Green Beret of the Testability Corps'),]
badge_printer = BadgePrinter(registrants, filename='test_rendering_unicode.pdf')
badge_printer.drawBadges()
def testRenderBadges(self):
registrants = [
Registrant('time', 'Jona1than Andrew Wolter', 'jwolter', 'US-MTV',
'Green Beret of the Testability Corps'),
Registrant('time', 'Jona2than Andrew Wolter', 'jwolter', 'US-MTV',
'Green Beret of the Testability Corps'),
Registrant('time', 'Jona3than Andrew Wolter', 'jwolter', 'US-MTV',
'Green Beret of the Testability Corps'),
Registrant('time', 'Jona4than Andrew Wolter', 'jwolter', 'US-MTV',
'Green Beret of the Testability Corps'),
Registrant('time', 'Jona5than Andrew Wolter', 'jwolter', 'US-MTV',
'Green Beret of the Testability Corps'),
Registrant('time', 'Jona6than Andrew Wolter', 'jwolter', 'US-MTV',
'Green Beret of the Testability Corps'),
Registrant('time', 'Jona7than Andrew Wolter', 'jwolter', 'US-MTV',
'Green Beret of the Testability Corps'),
Registrant('time', 'Jona8than Andrew Wolter', 'jwolter', 'US-MTV',
'Green Beret of the Testability Corps'),
]
printer = BadgePrinter(registrants, filename='test_all_badges_tmp.pdf')
printer.drawBadges()
# manually do a visual inspection
def testChunkListintoSixes(self):
to_chunk = range(1, 9) # list from 1 to 8, inclusive
printer = BadgePrinter(to_chunk, 'test_chunk_tmp.pdf',)
chunked = printer._chunkRegistrantsIntoSixes()
self.assertEqual(2, len(chunked))
self.assertEqual(6, len(chunked[0]))
self.assertEqual(2, len(chunked[1]))
to_chunk = range(1, 7) # list from 1 to 6, inclusive
printer = BadgePrinter(to_chunk, 'test_chunk_tmp.pdf')
chunked = printer._chunkRegistrantsIntoSixes()
self.assertEqual(1, len(chunked))
self.assertEqual(6, len(chunked[0]))
to_chunk = []
printer = BadgePrinter(to_chunk, 'test_chunk_tmp.pdf')
chunked = printer._chunkRegistrantsIntoSixes()
self.assertEqual(0, len(chunked))
if __name__ == '__main__':
unittest.main()