def test_email_addrs_to_return_list_of_not_null_email_addresses(self): site_conf = SiteConfiguration() site_conf._email_addr_to_1 = '*****@*****.**' site_conf._email_addr_to_2 = '*****@*****.**' site_conf._email_addr_to_3 = '*****@*****.**' assert set(site_conf.email_addrs_to) == { '*****@*****.**', '*****@*****.**', '*****@*****.**' }
def test_email_addrs_to_return_list_of_not_null_email_addresses( self): site_conf = SiteConfiguration() site_conf._email_addr_to_1 = '*****@*****.**' site_conf._email_addr_to_2 = '*****@*****.**' site_conf._email_addr_to_3 = '*****@*****.**' assert set(site_conf.email_addrs_to) == {'*****@*****.**', '*****@*****.**', '*****@*****.**'}
def test_email_is_sent_to_operators(self): site_conf = SiteConfiguration( site=Site.objects.get(pk=current_site_id())) site_conf._email_addr_from = '*****@*****.**' site_conf._email_addr_to_1 = '*****@*****.**' site_conf.save() self.form.submit('_save') self.assertEqual(len(mail.outbox), 1) email = mail.outbox[0] """:type : django.core.mail.EmailMessage""" self.assertEqual(email.subject, "New ticket created by {}".format(self.user.username)) self.assertSetEqual(set(email.to), set(site_conf.email_addrs_to)) self.assertEqual(email.from_email, site_conf.email_addr_from)
def test_get_no_site_email_add_from_return_settings_server_email(self): with patch('openhelpdesk.models.settings', SERVER_EMAIL='*****@*****.**'): assert (SiteConfiguration.get_no_site_email_addr_from() == '*****@*****.**')
def test_email_add_from_return_settings_server_email(self): site_conf = SiteConfiguration() site_conf._email_addr_from = None with patch('openhelpdesk.models.settings', SERVER_EMAIL='*****@*****.**'): assert site_conf.email_addr_from == '*****@*****.**'
def test_email_add_from_return_field_value_isnt_none(self): site_conf = SiteConfiguration() site_conf._email_addr_from = '*****@*****.**' assert site_conf.email_addr_from == '*****@*****.**'
def test_mail_addrs_to_return_empty_list_if_all_null_email_addresses(self): site_conf = SiteConfiguration() assert site_conf.email_addrs_to == list()
def test_unicode_method(self): with patch.object(SiteConfiguration, 'site', __unicode__=lambda x: 'site foo'): site_conf = SiteConfiguration() assert str(site_conf) == 'site foo'
def test_str_method(self): with patch.object(SiteConfiguration, 'site', __str__=lambda x: 'site foo'): site_conf = SiteConfiguration() assert site_conf.__str__() == 'site foo'