Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement