コード例 #1
0
ファイル: test.py プロジェクト: imclab/qrtag
    def setUp(self):
        codes = ['http://twitter.com/' + "".join(sample(letters, self.code_length)) for dummy 
                in range(self.sticker_count)]
        lines = [choice(self.first_names) + ' ' + choice(self.last_names) for dummy 
                in range(self.sticker_count)]

        stickers = [Sticker(c, l) for c, l in zip(codes, lines)]
        self.maker = PDFMaker(self.out_file, stickers)
コード例 #2
0
ファイル: test.py プロジェクト: imclab/qrtag
class PDFMakerTest(unittest.TestCase):
    sticker_count = 100
    code_length = 25
    out_file = 'pdfmakertest.pdf'
    first_names = [
        'Simon',
        'Åsa',
        'Torbjörn',
        'Gåsa',
        'Lännart',
        'Älin',
        'Örban',
    ]
    last_names = [
        'Anderssån',
        'Erikssån',
        'Svänzzon',
        'Örnvinge',
        'Ågren',
        'Silversköld',
    ]

    def setUp(self):
        codes = ['http://twitter.com/' + "".join(sample(letters, self.code_length)) for dummy 
                in range(self.sticker_count)]
        lines = [choice(self.first_names) + ' ' + choice(self.last_names) for dummy 
                in range(self.sticker_count)]

        stickers = [Sticker(c, l) for c, l in zip(codes, lines)]
        self.maker = PDFMaker(self.out_file, stickers)

    def test_build(self):
        """Make sure that the out file exists and that it is a PDF file."""
        self.maker.build()
        self.assertTrue(os.path.isfile(self.out_file))
        with open(self.out_file, 'r') as f:
            header_line = f.readlines()[0]
            self.assertTrue(header_line.startswith('%PDF-'))