Пример #1
0
 def test_generate_csv(self):
     """
     test creation of csv snippet
     """
     from c3sintent.utils import generate_csv
     my_appstruct = {
         'activity': ['composer', 'dj'],
         'firstname': 'John',
         'lastname': 'Doe',
         'address1': 'In the Middle',
         'address2': 'Of Nowhere',
         'postCode': '12345',
         'city': 'My Town',
         'email': '*****@*****.**',
         'region': 'Hessen',
         'country': 'de',
         'at_least_three_works': 'yes',
         'member_of_colsoc': 'yes',
         'understood_declaration': 'yes',
         'consider_joining': 'yes',
         'noticed_dataProtection': 'yes'
         }
     result = generate_csv(my_appstruct)
     #print(result)
     from datetime import date
     today = date.today().strftime("%Y-%m-%d")
     #print(today)
     self.failUnless(
         result == str(today + ';unknown;pending...;John;Doe;' +
                       '[email protected];In the Middle;Of Nowhere;' +
                       '12345;My Town;Hessen;de;j;n;n;n;n;j;j;j;j;j;j'))
Пример #2
0
    def test_generate_csv(self):
        """
        test creation of csv snippet
        """
        from c3sintent.utils import generate_csv
        my_appstruct = {
            'activity': ['composer', 'dj'],
            'firstname': u'Jöhn',
            'lastname': u'Doe',
#            'address1': 'In the Middle',
#            'address2': 'Of Nowhere',
#            'postCode': '12345',
            'city': u'My Town',
            'email': u'*****@*****.**',
#            'region': 'Hessen',
            'country': u'de',
            'date_of_birth': u'1987-06-05',
            'member_of_colsoc': u'yes',
            'name_of_colsoc': u'GEMA FöTT',
            'opt_URL': u'http://foo.bar.baz',
            'opt_band': u'Moin Meldn',
            'consider_joining': u'yes',
            'noticed_dataProtection': u'yes',
            'invest_member': u'yes'
        }
        result = generate_csv(my_appstruct)
        #print("test_generate_csv: the result: %s") % result
        from datetime import date
        today = date.today().strftime("%Y-%m-%d")
        expected_result = today + ',pending...,Jöhn,Doe,[email protected],My Town,de,j,http://foo.bar.baz,Moin Meldn,1987-06-05,j,n,n,n,j,j,GEMA FöTT,j\r\n'
        # note the \r\n at the end: that is line-ending foo!

        #print("type of today: %s ") % type(today)
        #print("type of result: %s ") % type(result)
        #print("type of expected_result: %s ") % type(expected_result)
        #print("result: \n%s ") % (result)
        #print("expected_result: \n%s ") % (expected_result)
        self.assertEqual(result, expected_result)