def test_generate_pdf_de(self): """ Test pdf generation and resulting pdf size """ from c3sintent.views import generate_pdf mock_appstruct = { 'firstname': u'Anne', 'lastname': u'Gilles', 'address1': u'Sonnenstraße 23', 'address2': u'irgendwo', 'postCode': u'12345', 'city': u'12345 Müsterstädt', 'email': u'*****@*****.**', 'region': u'my region', 'country': u'my country', 'activity': set([u'composer', u'lyricist', u'dj']), 'at_least_three_works': 'at_least_three_works', 'member_of_colsoc': 'member_of_colsoc', 'understood_declaration': 'understood_declaration', 'consider_joining': 'consider_joining', 'noticed_dataProtection': 'noticed_dataProtection', '_LOCALE_': 'de', } # a skipTest iff pdftk is not installed import subprocess from subprocess import CalledProcessError try: res = subprocess.check_call( ["which", "pdftk"], stdout=None) if res == 0: # go ahead with the tests result = generate_pdf(mock_appstruct) self.assertEquals(result.content_type, 'application/pdf') #print("size of pdf: " + str(len(result.body))) # check pdf size self.assertTrue(100000 > len(result.body) > 78000) # TODO: check pdf for contents except CalledProcessError, cpe: # pragma: no cover print("pdftk not installed. skipping test!") print(cpe)
def test_generate_pdf_de(self): """ Test pdf generation and resulting pdf size """ from c3sintent.views import generate_pdf mock_appstruct = { 'firstname': u'Anne', 'lastname': u'Gilles', 'city': u'Müsterstädt', 'email': u'*****@*****.**', 'date_of_birth': u'1987-06-05', 'country': u'my country', 'activity': set([u'composer', u'lyricist', u'dj']), 'opt_band': u'Moin Meldön', 'opt_URL': 'http://moin.meldon.foo', 'member_of_colsoc': 'member_of_colsoc', 'name_of_colsoc': 'Foo colsoc', 'invest_member': 'yes', 'noticed_dataProtection': 'noticed_dataProtection', '_LOCALE_': 'de', } # a skipTest iff pdftk is not installed import subprocess from subprocess import CalledProcessError try: res = subprocess.check_call( ["which", "pdftk"], stdout=None) if res == 0: # go ahead with the tests result = generate_pdf(mock_appstruct) self.assertEquals(result.content_type, 'application/pdf') #print("size of pdf: " + str(len(result.body))) # check pdf size self.assertTrue(100000 > len(result.body) > 50000) # TODO: check pdf for contents except CalledProcessError, cpe: # pragma: no cover print("pdftk not installed. skipping test!") print(cpe)