Beispiel #1
0
 def test_build_csv_custom_url(self, csv_mock, tmp_file_mock, os_mock):
     tmp_file_mock.return_value = (0, self.filename)
     writer_mock = Mock()
     csv_mock.writer.return_value = writer_mock
     url = 'http://www.google.com'
     user = facebook.client.get_user(1, 1)
     edge_collection = {
         self.notification_user.uuid: facebook.client.get_friend_edges(user, 1)
     }
     faces_email.build_csv(
         edge_collection.iteritems(), 3,
         self.campaign, self.content, url
     )
     assert writer_mock.writerow.called
     assert 'http://www.google.com?efuuid=1' in writer_mock.writerow.call_args[0][0][4]
     self.assertEqual(
         writer_mock.writerow.call_args[0][0][1],
         '*****@*****.**'
     )
     self.assertEqual(
         relational.NotificationEvent.objects.filter(
             event_type='shown').count(),
         3
     )
     assert relational.NotificationEvent.objects.filter(
         event_type='generated').exists()
Beispiel #2
0
 def test_build_csv(self, csv_mock, tmp_file_mock, os_mock):
     ''' Tests the build_csv method '''
     tmp_file_mock.return_value = (0, self.filename)
     writer_mock = Mock()
     csv_mock.writer.return_value = writer_mock
     user = facebook.client.get_user(1, 1)
     edge_collection = {
         self.notification_user.uuid: facebook.client.get_friend_edges(user, 1)
     }
     faces_email.build_csv(
         edge_collection.iteritems(), 3,
         self.campaign, self.content, None
     )
     assert writer_mock.writerow.called
     assert writer_mock.writerow.call_args[0][0][4].strip().startswith('<table')
     self.assertEqual(
         writer_mock.writerow.call_args[0][0][1],
         '*****@*****.**'
     )
     self.assertEqual(
         relational.NotificationEvent.objects.filter(
             event_type='shown').count(),
         3
     )
     assert relational.NotificationEvent.objects.filter(
         event_type='generated').exists()