def test_basic_only_following_false_group_subscription_with_unsubscribed( self): source = G(Source) ek = G(EntityKind) e = G(Entity, entity_kind=ek) se = G(Entity) G(EntityRelationship, sub_entity=e, super_entity=se) other_e = G(Entity, entity_kind=ek) G(EntityRelationship, sub_entity=other_e, super_entity=se) G(Subscription, entity=se, sub_entity_kind=ek, source=source, medium=self.email_medium, only_following=False) G(Unsubscription, entity=e, source=source, medium=self.email_medium) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', } event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=e) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() self.assertEquals(set(email.recipients.all()), set([other_e])) self.assertEquals(email.event.context, email_context) self.assertEquals(email.subject, '') self.assertEquals(email.scheduled, datetime(2013, 1, 2))
def test_multiple_events_only_following_true(self): source = G(Source) e = G(Entity) other_e = G(Entity) G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=True) G(Subscription, entity=other_e, source=source, medium=self.email_medium, only_following=True) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', } G(Event, source=source, context=email_context) event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=e) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() self.assertEquals(set(email.recipients.all()), set([e])) self.assertEquals(email.event.context, email_context) self.assertEquals(email.subject, '') self.assertEquals(email.scheduled, datetime(2013, 1, 2))
def test_basic_only_following_false_group_subscription_with_unsubscribed(self): source = G(Source) ek = G(EntityKind) e = G(Entity, entity_kind=ek) se = G(Entity) G(EntityRelationship, sub_entity=e, super_entity=se) other_e = G(Entity, entity_kind=ek) G(EntityRelationship, sub_entity=other_e, super_entity=se) G(Subscription, entity=se, sub_entity_kind=ek, source=source, medium=self.email_medium, only_following=False) G(Unsubscription, entity=e, source=source, medium=self.email_medium) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', } event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=e) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() self.assertEquals(set(email.recipients.all()), set([other_e])) self.assertEquals(email.event.context, email_context) self.assertEquals(email.subject, '') self.assertEquals(email.scheduled, datetime(2013, 1, 2))
def test_basic_only_following_true_subscription(self): source = G(Source) e = G(Entity) se = G(Entity) G(EntityRelationship, sub_entity=e, super_entity=se) other_e = G(Entity) G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=True) G(Subscription, entity=other_e, source=source, medium=self.email_medium, only_following=True) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', } event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=se) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() # Since the other_e entity does not follow the se entity, only the e entity receives an email self.assertEquals(set(email.recipients.all()), set([e])) self.assertEquals(email.event.context, email_context) self.assertEquals(email.subject, '') self.assertEquals(email.scheduled, datetime(2013, 1, 2))
def test_custom_from_email(self): source = G(Source) e = G(Entity) G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=False, sub_entity_kind=None) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', 'from_address': '*****@*****.**' } event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=e) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() self.assertEqual(email.from_address, '*****@*****.**')
def test_default_from_email(self): # settings.DEFAULT_FROM_EMAIL is already set to [email protected] source = G(Source) e = G(Entity) G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=False, sub_entity_kind=None) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', } event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=e) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() self.assertEqual(email.from_address, '*****@*****.**')
def test_basic_only_following_false_subscription(self): source = G(Source) e = G(Entity) G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=False, sub_entity_kind=None) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', } event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=e) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() self.assertEquals(list(email.recipients.all()), [e]) self.assertEquals(email.event.context, email_context) self.assertEquals(email.subject, '') self.assertEquals(email.scheduled, datetime(2013, 1, 2))
def test_custom_from_email(self): source = G(Source) e = G(Entity) G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=False, sub_entity_kind=None) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', 'from_address': '*****@*****.**' } event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=e) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() self.assertEqual(email.from_address, '*****@*****.**')
def test_default_from_email(self): # settings.DEFAULT_FROM_EMAIL is already set to [email protected] source = G(Source) e = G(Entity) G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=False, sub_entity_kind=None) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', } event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=e) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() self.assertEqual(email.from_address, '*****@*****.**')
def test_multiple_events_only_following_true(self): source = G(Source) e = G(Entity) other_e = G(Entity) G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=True) G(Subscription, entity=other_e, source=source, medium=self.email_medium, only_following=True) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', } G(Event, source=source, context=email_context) event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=e) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() self.assertEquals(set(email.recipients.all()), set([e])) self.assertEquals(email.event.context, email_context) self.assertEquals(email.subject, '') self.assertEquals(email.scheduled, datetime(2013, 1, 2))
def test_basic_only_following_false_subscription(self): source = G(Source) e = G(Entity) G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=False, sub_entity_kind=None) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', } event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=e) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() self.assertEquals(list(email.recipients.all()), [e]) self.assertEquals(email.event.context, email_context) self.assertEquals(email.subject, '') self.assertEquals(email.scheduled, datetime(2013, 1, 2))
def test_basic_only_following_true_subscription(self): source = G(Source) e = G(Entity) se = G(Entity) G(EntityRelationship, sub_entity=e, super_entity=se) other_e = G(Entity) G(Subscription, entity=e, source=source, medium=self.email_medium, only_following=True) G(Subscription, entity=other_e, source=source, medium=self.email_medium, only_following=True) email_context = { 'entity_emailer_template': 'template', 'entity_emailer_subject': 'hi', } event = G(Event, source=source, context=email_context) G(EventActor, event=event, entity=se) EntityEmailerInterface.convert_events_to_emails() email = Email.objects.get() # Since the other_e entity does not follow the se entity, only the e entity receives an email self.assertEquals(set(email.recipients.all()), set([e])) self.assertEquals(email.event.context, email_context) self.assertEquals(email.subject, '') self.assertEquals(email.scheduled, datetime(2013, 1, 2))
def test_no_subscriptions(self): G(Event, context={}) EntityEmailerInterface.convert_events_to_emails() self.assertFalse(Email.objects.exists())
def test_no_events(self): EntityEmailerInterface.convert_events_to_emails() self.assertFalse(Email.objects.exists())
def test_no_subscriptions(self): G(Event, context={}) EntityEmailerInterface.convert_events_to_emails() self.assertFalse(Email.objects.exists())
def test_no_events(self): EntityEmailerInterface.convert_events_to_emails() self.assertFalse(Email.objects.exists())