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 init_company_subscriber_without_name(self):
     """Initialize a subscriber without name info but with company info."""
     sub = Subscriber()
     sub.company = 'Google'
     a = Address()
     a.address1 = 'Address'
     a.city = 'USA'
     sub.address = a
     sub.issues_to_receive = 0
     sub.save()
Exemplo n.º 3
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.º 4
0
    def test_get_subs_by_email(self):
        """Test subscriber by email retrieval using the adapter"""
        sub = Subscriber()
        sub.lastname = 'toto'
        sub.firstname = 'tata'
        sub.company = 'Machin.corp'
        sub.email_address = '*****@*****.**'
        sub.name_addition = 'foobar'
        sub.save()

        dict_list = SubscriberAdapter.get_subscribers_from_email('*****@*****.**')
        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('Machin.corp', new_sub['company'])
        self.assertEquals(sub.identifier, new_sub['subscriber_id'])