def test_returns_own_email(self):
     entity_1 = G(Entity, entity_meta={'email': '*****@*****.**'})
     entity_2 = G(Entity, entity_meta={'email': '*****@*****.**'})
     email = g_email(recipients=[entity_1, entity_2], context={})
     addresses = tasks.get_subscribed_email_addresses(email)
     expected_addresses = {u'*****@*****.**', u'*****@*****.**'}
     self.assertEqual(set(addresses), expected_addresses)
    def test_get_emails_override_email_key_exclude_key(self):
        e1 = G(Entity, entity_meta={'email_address': '*****@*****.**'})
        e2 = G(Entity, entity_meta={'email_address': '*****@*****.**'})
        email = g_email(recipients=[e1, e2], context={})

        addresses = tasks.get_subscribed_email_addresses(email)
        self.assertEqual(set(addresses), set(['*****@*****.**', '*****@*****.**']))
 def test_returns_own_email(self):
     G(Subscription, entity=self.super_entity, subentity_type=None, medium=self.medium, source=self.source)
     email = N(
         Email, source=self.source, send_to=self.super_entity,
         subentity_type=None, template=self.template, context={}
     )
     addresses = tasks.get_subscribed_email_addresses(email)
     expected_addresses = {u'*****@*****.**'}
     self.assertEqual(set(addresses), expected_addresses)
 def test_unsubscription_works(self):
     G(Subscription, entity=self.super_entity, subentity_type=self.ct, medium=self.medium, source=self.source)
     G(Unsubscribe, entity=self.sub_entity_1, source=self.source, medium=self.medium)
     email = N(
         Email, send_to=self.super_entity, subentity_type=self.ct,
         source=self.source, template=self.template, context={}
     )
     addresses = tasks.get_subscribed_email_addresses(email)
     expected_addresses = {u'*****@*****.**'}
     self.assertEqual(set(addresses), expected_addresses)
 def test_email_settings(self):
     custom_medium_name = 'test_medium'
     other_medium = G(Medium, name=custom_medium_name)
     G(Subscription, entity=self.super_entity, subentity_type=self.ct, medium=other_medium, source=self.source)
     email = N(
         Email, source=self.source, send_to=self.super_entity,
         subentity_type=self.ct, template=self.template, context={}
     )
     expected_addresses = {u'*****@*****.**', u'*****@*****.**'}
     with self.settings(ENTITY_EMAILER_MEDIUM_NAME=custom_medium_name):
         addresses = tasks.get_subscribed_email_addresses(email)
     self.assertEqual(set(addresses), expected_addresses)
 def test_returns_own_email(self):
     G(Subscription,
       entity=self.super_entity,
       subentity_type=None,
       medium=self.medium,
       source=self.source)
     email = N(Email,
               source=self.source,
               send_to=self.super_entity,
               subentity_type=None,
               template=self.template,
               context={})
     addresses = tasks.get_subscribed_email_addresses(email)
     expected_addresses = {u'*****@*****.**'}
     self.assertEqual(set(addresses), expected_addresses)
 def test_unsubscription_works(self):
     G(Subscription,
       entity=self.super_entity,
       subentity_type=self.ct,
       medium=self.medium,
       source=self.source)
     G(Unsubscribe,
       entity=self.sub_entity_1,
       source=self.source,
       medium=self.medium)
     email = N(Email,
               send_to=self.super_entity,
               subentity_type=self.ct,
               source=self.source,
               template=self.template,
               context={})
     addresses = tasks.get_subscribed_email_addresses(email)
     expected_addresses = {u'*****@*****.**'}
     self.assertEqual(set(addresses), expected_addresses)
 def test_email_settings(self):
     custom_medium_name = 'test_medium'
     other_medium = G(Medium, name=custom_medium_name)
     G(Subscription,
       entity=self.super_entity,
       subentity_type=self.ct,
       medium=other_medium,
       source=self.source)
     email = N(Email,
               source=self.source,
               send_to=self.super_entity,
               subentity_type=self.ct,
               template=self.template,
               context={})
     expected_addresses = {
         u'*****@*****.**', u'*****@*****.**'
     }
     with self.settings(ENTITY_EMAILER_MEDIUM_NAME=custom_medium_name):
         addresses = tasks.get_subscribed_email_addresses(email)
     self.assertEqual(set(addresses), expected_addresses)
 def test_no_recipients(self):
     email = g_email(recipients=[], context={})
     addresses = tasks.get_subscribed_email_addresses(email)
     self.assertEqual(addresses, [])