Example #1
0
 def setUp(self):
     self.test_feedback = Feedback(
         email='*****@*****.**',
         comment="Sparks on the curb.",
         is_helpful=True,
         referrer="http://www.consumerfinance.gov/owing-a-home/",
         submitted_on=datetime.datetime.now())
     self.test_feedback.save()
Example #2
0
 def test_assemble_csv(self):
     test_csv = Feedback().assemble_csv(Feedback.objects.all())
     for term in ["comment",
                  "Sparks on the curb",
                  "*****@*****.**",
                  "{}".format(self.test_feedback.submitted_on.date())]:
         self.assertIn(term, test_csv)
Example #3
0
class TestFeedbackModel(TestCase):
    def setUp(self):
        self.test_feedback = Feedback(
            email='*****@*****.**',
            comment="Sparks on the curb.",
            is_helpful=True,
            referrer="http://www.consumerfinance.gov/owing-a-home/",
            submitted_on=datetime.datetime.now())
        self.test_feedback.save()

    def test_assemble_csv(self):
        test_csv = Feedback().assemble_csv(Feedback.objects.all())
        for term in [
                "comment", "Sparks on the curb", "*****@*****.**",
                "{}".format(self.test_feedback.submitted_on.date())
        ]:
            self.assertIn(term, test_csv)
Example #4
0
 def setUp(self):
     self.test_feedback = Feedback(
         email='*****@*****.**',
         comment="Sparks on the curb.",
         is_helpful=True,
         referrer="https://www.consumerfinance.gov/owing-a-home/",
         submitted_on=datetime.datetime.now()
     )
     self.test_feedback.save()
Example #5
0
class TestFeedbackModel(TestCase):
    def setUp(self):
        self.test_feedback = Feedback(
            email='*****@*****.**',
            comment="Sparks on the curb.",
            is_helpful=True,
            referrer="https://www.consumerfinance.gov/owing-a-home/",
            submitted_on=datetime.datetime.now()
        )
        self.test_feedback.save()

    def test_assemble_csv(self):
        test_csv = Feedback().assemble_csv(Feedback.objects.all())
        for term in ["comment",
                     "Sparks on the curb",
                     "*****@*****.**",
                     "{}".format(self.test_feedback.submitted_on.date())]:
            self.assertIn(term, test_csv)
Example #6
0
 def export_selection_as_csv(self, request, queryset):
     object_name = queryset.model._meta.object_name
     user = request.user
     subject = "CFPB website {} download"
     message = 'A CSV file of selected {} records is attached.'
     fromline = '*****@*****.**'
     user_message = "Sent {} selected {} records as CSV to {}"
     recipients = [user.email]
     csvfile = Feedback().assemble_csv(queryset)
     email = EmailMessage(subject.format(object_name),
                          message.format(object_name), fromline, recipients)
     email.attach('Feedbacks.csv', csvfile)
     email.send()
     self.message_user(
         request,
         user_message.format(queryset.count(), object_name,
                             ", ".join(recipients)))