Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    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')
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 def save_basic_subscriber(self):
     sub = Subscriber()
     sub.lastname = 'Doe'
     sub.firstname = 'John'
     sub.company = 'Apave'
     a = Address()
     a.city = 'Rouen'
     sub.address = a
     sub.issues_to_receive = 5
     sub.hors_serie1 = 6
     sub.subscription_price = 20
     sub.membership_price = 30
     sub.subscription_date = datetime.date(2011, 07, 12)
     sub.save()
Exemplo n.º 5
0
    def test_get_subs_by_lastname(self):
        """Test subscriber by lastname retrieval using the adapter"""
        sub = Subscriber()
        sub.lastname = 'toto'
        sub.firstname = 'tata'
        sub.email_address = '*****@*****.**'
        sub.name_addition = 'foobar'
        sub.save()

        dict_list = SubscriberAdapter.get_subscribers_from_lastname('toto')
        new_sub = dict_list[0]
        self.assertEquals('toto', new_sub['lastname'])
        self.assertEquals('tata', new_sub['firstname'])
        self.assertEquals('*****@*****.**', new_sub['email_address'])
        self.assertEquals('foobar', new_sub['name_addition'])
        self.assertEquals(sub.identifier, new_sub['subscriber_id'])
Exemplo n.º 6
0
 def test_handle_name_addition(self):
     """Tests that if we have a name_addition, it goes in the first address
     field"""
     subscriber = Subscriber()
     subscriber.issues_to_receive = 1
     subscriber.lastname = 'Dupond'
     subscriber.firstname = 'Toto'
     subscriber.name_addition = 'Chez lulu'
     a = Address()
     a.address1 = '14 Rue lalala'
     subscriber.address = a
     subscriber.save()
     line = self.export_and_get_first_line()
     splitted = line.split('\t')
     self.assertEqual('CHEZ LULU', splitted[5])
     self.assertEqual('14 RUE LALALA', splitted[6])
Exemplo n.º 7
0
    def test_subscriber_with_id(self):
        db_sub = Subscriber()
        db_sub.lastname = 'toto'
        db_sub.firstname = 'tata'
        db_sub.save()
        ident = db_sub.identifier
        sub = {
                'subscriber_id': ident,
                'lastname': 'toto',
                'firstname': 'titi'
                }
        actual = self._save(sub)
        self.assertEquals(ident, actual['subscriber_id'])

        subs_list = Subscriber.get_subscribers_from_lastname('toto')
        self.assertEqual(len(subs_list), 1)

        retrieved_sub = subs_list[0]
        self.assertEquals(ident, retrieved_sub.identifier)
Exemplo n.º 8
0
 def save_accent_subscriber(self):
     sub = Subscriber()
     sub.lastname = u'Yé'
     sub.firstname = u'Bébé'
     sub.save()
Exemplo n.º 9
0
 def save_wrong_date_subscriber(self):
     sub = Subscriber()
     sub.lastname = 'Doe'
     sub.firstname = 'John'
     sub.subscription_date = datetime.date(211, 07, 12)
     sub.save()