def test_generate_pdf_de(self): """ Test pdf generation and resulting pdf size """ from c3smembership.views import generate_pdf mock_appstruct = { 'firstname': u'Anne', 'lastname': u'Gilles', 'address1': u'addr one', 'address2': u'addr two', 'postcode': u'54321', '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': u'yes', 'membership_type': 'investing', #'noticed_dataProtection': 'noticed_dataProtection', 'num_shares': u'23', '_LOCALE_': 'de', 'date_of_submission': '2013-09-09 08:44:47.251588', } # 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))) #print(result) # 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)
def test_generate_pdf_de(self): """ Test pdf generation and resulting pdf size """ from c3smembership.views import generate_pdf mock_appstruct = { 'firstname': u'Anne', 'lastname': u'Gilles', 'address1': u'addr one', 'address2': u'addr two', 'postcode': u'54321', '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': u'yes', 'membership_type': 'investing', #'noticed_dataProtection': 'noticed_dataProtection', 'num_shares': u'23', '_LOCALE_': 'de', 'date_of_submission': '2013-09-09 08:44:47.251588', } # 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))) #print(result) # 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)
def test_generate_pdf_en(self): """ Test pdf generation and resulting pdf size """ from c3smembership.views import generate_pdf mock_appstruct = { 'firstname': u'Anne', 'lastname': u'Gilles', 'email': u'*****@*****.**', 'email_confirm_code': u'1234567890', 'date_of_birth': '1987-06-05', 'address1': 'addr one', 'address2': 'addr two', 'postcode': u'54321', 'city': u'Müsterstädt', 'country': u'some country', 'member_of_colsoc': 'member_of_colsoc', 'name_of_colsoc': 'Foo Colsoc', 'membership_type': 'investing', 'num_shares': '42', '_LOCALE_': 'en', 'date_of_submission': '2013-09-09 08:44:47.251588', } # 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(120000 > len(result.body) > 50000) # TODO: check pdf for contents except CalledProcessError, cpe: # pragma: no cover print("pdftk not installed. skipping test!") print(cpe)