def test_empty_email(self): """Tests what appens when a subscriber has no email""" subscriber = Subscriber() subscriber.email_address = '*****@*****.**' subscriber.issues_to_receive = 0 subscriber.save() subscriber = Subscriber() subscriber.email_address = '' subscriber.issues_to_receive = 0 subscriber.save() lines = self.export_and_get_lines() self.assertEqual('[email protected]\n', lines)
def test_two_email(self): """Tests when we have two emails in generated file""" subscriber = Subscriber() subscriber.email_address = '*****@*****.**' subscriber.issues_to_receive = 0 subscriber.save() subscriber = Subscriber() subscriber.email_address = '*****@*****.**' subscriber.issues_to_receive = 0 subscriber.save() lines = self.export_and_get_lines() self.assertEqual('[email protected]\[email protected]\n', lines)
def test_email_in_lowercase(self): """Tests that in generated file, the emails are in lower case""" subscriber = Subscriber() subscriber.issues_to_receive = 0 subscriber.email_address = '*****@*****.**' subscriber.save() lines = self.export_and_get_lines() self.assertEqual('*****@*****.**', lines.strip())
def test_remaining_issues_subscriber(self): """Tests when the subscriber has remaining issues""" subs = Subscriber() subs.issues_to_receive = 1 subs.email_address = '*****@*****.**' subs.save() lines = self.export_and_get_lines() self.assertEqual('', lines)
def test_one_email(self): """Test retrieval of one subscriber's email""" subscriber = Subscriber() subscriber.issues_to_receive = 0 subscriber.email_address = '*****@*****.**' subscriber.save() lines = self.export_and_get_lines() self.assertEqual('*****@*****.**', lines.strip())
def test_subscriber_with_regular_and_special(self): """Test when subscriber has both remaining regular and special issues""" subs = Subscriber() subs.issues_to_receive = 1 subs.hors_serie1 = 1 subs.email_address = '*****@*****.**' subs.save() lines = self.export_and_get_lines() self.assertEqual('', lines)
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'])