Skip to content

Instantly share code, notes, and snippets.

@d4vsanchez
Created August 21, 2017 21:21
Show Gist options
  • Save d4vsanchez/70bc5a07ace9cdda08179bd6bbb9eee9 to your computer and use it in GitHub Desktop.
Save d4vsanchez/70bc5a07ace9cdda08179bd6bbb9eee9 to your computer and use it in GitHub Desktop.
First version of the tests for the report model example
from django.core import mail
from django.test import TestCase
from reports.models.report import Report
class ReportTest(TestCase):
def tearDown(self):
Report.objects.all().delete()
mail.outbox = []
def test_create_report_and_send_by_email(self):
info = # This is a dict with the information of the fake Report
report = Report.objects.create(**info)
# There shouldn't be emails in the outbox
self.assertEqual(len(mail.outbox), 0)
report.create_report_and_send_by_email(self)
# There should be one email in the outbox
self.assertEqual(len(mail.outbox), 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment