def test_first_line(self):
        """Test if the first line of generated file is well written"""

        subs = Subscriber()
        subs.lastname = 'Debelle'
        subs.firstname = 'Anne'
        a = Address()
        a.address1 = 'rue dupre 63'
        a.address2 = 'Bruxelles 1090'
        a.city = 'belgique'
        subs.address = a
        subs.issues_to_receive = 1
        subs.save()

        line = self.export_and_get_first_line()

        self.assertTrue(line is not None)

        splitted_line = line.split('\t')
        self.assertEquals(splitted_line[2], u'DEBELLE')
        self.assertEquals(splitted_line[3], u'ANNE')
        self.assertEquals(splitted_line[4], u'')
        self.assertEquals(splitted_line[5], u'')
        self.assertEquals(splitted_line[6], u'RUE DUPRE 63')
        self.assertEquals(splitted_line[7], u'BRUXELLES 1090')
        self.assertEquals(splitted_line[8], u'')
        self.assertEquals(splitted_line[9], u'BELGIQUE')
        self.assertEquals(splitted_line[10], u'')
        self.assertEquals(splitted_line[11], u'')
        self.assertEquals(splitted_line[12], u'')
        self.assertEquals(splitted_line[13], u'')
        self.assertEquals(splitted_line[14], u'')
        self.assertEquals(splitted_line[15], u'\n')
    def test_field_length(self):
        """test if the fields in the output file does not exceed character limits"""
        big_string = ''.join(['b' for i in xrange(1, 40)])
        subscriber = Subscriber()
        subscriber.lastname = big_string
        subscriber.firstname = big_string
        subscriber.company = big_string
        a = Address()
        a.address1 = big_string
        a.address2 = big_string
        a.post_code = 123456 
        a.city = big_string
        subscriber.address = a
        subscriber.issues_to_receive = 10
        subscriber.save()
        line = self.export_and_get_first_line()

        splitted_line = line.split('\t')
        self.assertTrue(len(splitted_line[0]) <= 20)
        self.assertTrue(len(splitted_line[1]) <= 12)
        self.assertTrue(len(splitted_line[2]) <= 32)
        self.assertTrue(len(splitted_line[3]) <= 20)
        self.assertTrue(len(splitted_line[4]) <= 32)
        self.assertTrue(len(splitted_line[5]) <= 32)
        self.assertTrue(len(splitted_line[6]) <= 32)
        self.assertTrue(len(splitted_line[7]) <= 32)
        self.assertTrue(len(splitted_line[8]) <= 5)
        self.assertTrue(len(splitted_line[9]) <= 26)
        self.assertTrue(len(splitted_line[10]) <= 8)
        self.assertTrue(len(splitted_line[11]) <= 3)
        self.assertTrue(len(splitted_line[12]) <= 32)
        self.assertTrue(len(splitted_line[13]) <= 32)
        self.assertTrue(len(splitted_line[14]) <= 32)
        self.assertTrue(len(splitted_line[15]) <= 32)
 def set_regular_subscriber(self):
     sub = Subscriber()
     sub.lastname = 'Nom'
     sub.firstname = 'Prenom'
     sub.name_addition = 'NameAddition'
     a = Address()
     a.address1 = 'Adresse'
     a.address2 = 'Addition'
     a.post_code = 12345
     a.city = 'Ville'
     sub.address = a
     return sub
Exemple #4
0
    def test_subscriber_address(self):
        sub = Subscriber()
        address = Address()
        sub.lastname = 'toto'
        address.address1 = '11 rue bilou'
        address.address2 = 'batiment 1'
        address.post_code = '66066'
        address.city = 'NYC'
        sub.address = address
        sub.save()

        retrieved_sub = Subscriber.get_subscribers_from_lastname('toto')[0]
        retieved_address = retrieved_sub.address
        self.assertEqual('NYC', retieved_address.city)
Exemple #5
0
    def test_get_subs_address_by_lastname(self):
        """Tests address fields on dict retrieved by the adapter"""
        sub = Subscriber()
        sub.lastname = 'toto'
        address = Address()
        address.address1 = '42 rue truc'
        address.address2 = 'bat B'
        address.post_code = 38100
        address.city = 'Paris'
        sub.address = address
        sub.save()

        dict_list = SubscriberAdapter.get_subscribers_from_lastname('toto')
        new_sub = dict_list[0]
        self.assertEquals('42 rue truc', new_sub['address'])
        self.assertEquals('bat B', new_sub['address_addition'])
        self.assertEquals('38100', new_sub['post_code'])
        self.assertEquals('Paris', new_sub['city'])