Created
April 16, 2015 19:45
-
-
Save acmisiti/7763a7027f319d79cddc to your computer and use it in GitHub Desktop.
unit tests to fix issue 952 rewire
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Unit tests | |
@override_settings(CELERY_ALWAYS_EAGER = True, BROKER_BACKEND = 'memory') | |
def test_user_should_get_email_when_is_public_is_true_for_PRIMARY_OFFERINGS_ONLY(self): | |
""" | |
issue 952 fix | |
- if offering is primary and is_public goes from false to true then email should be sent | |
- if offering is not primary and is_public goes from false to true no email should be sent | |
""" | |
self.assertEqual(len(mail.outbox),0) | |
self.assertFalse(self.offering.is_public) | |
self.assertEquals(self.offering.offer_type, Offering.OFFERING_TYPE_PRIMARY) | |
self.offering.is_public = True | |
self.offering.save() | |
# two users so two emails should get sent | |
self.assertEqual(len(mail.outbox),2) | |
@override_settings(CELERY_ALWAYS_EAGER = True, BROKER_BACKEND = 'memory') | |
def test_user_should_not_get_email_when_is_public_is_true_for_ANYTHING_BESIDES_PRIMARY_OFFERING(self): | |
""" | |
issue 952 fix | |
- if offering is primary and is_public goes from false to true then email should be sent | |
- if offering is not primary and is_public goes from false to true no email should be sent | |
""" | |
self.offering.offer_type = Offering.OFFERING_TYPE_SECONDARY | |
self.offering.save() | |
self.assertEqual(len(mail.outbox),0) | |
self.assertFalse(self.offering.is_public) | |
self.assertEquals(self.offering.offer_type, Offering.OFFERING_TYPE_SECONDARY) | |
self.offering.is_public = True | |
self.offering.save() | |
self.assertEqual(len(mail.outbox),0) | |
Code | |
if 'is_public' in dirty_fields and instance.is_public and instance.offer_type == Offering.OFFERING_TYPE_PRIMARY: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment