class TestSendEmailBaseCommand(CacheIsolationTestCase): def setUp(self): self.command = SendEmailBaseCommand() self.site = SiteFactory() self.site_config = SiteConfigurationFactory.create(site=self.site) def test_handle(self): with patch.object(self.command, 'send_emails') as send_emails: self.command.handle(site_domain_name=self.site.domain, date='2017-09-29') send_emails.assert_called_once_with( self.site, datetime.datetime(2017, 9, 29, tzinfo=pytz.UTC), None ) def test_send_emails(self): with patch.multiple( self.command, offsets=(1, 3, 5), enqueue=DEFAULT, ): arg = Mock(name='arg') kwarg = Mock(name='kwarg') self.command.send_emails(arg, kwarg=kwarg) self.assertFalse(arg.called) self.assertFalse(kwarg.called) for offset in self.command.offsets: self.command.enqueue.assert_any_call(offset, arg, kwarg=kwarg)
class TestSendEmailBaseCommand(CacheIsolationTestCase): def setUp(self): self.command = SendEmailBaseCommand() self.site = SiteFactory() self.site_config = SiteConfigurationFactory.create(site=self.site) def test_handle(self): with patch.object(self.command, 'send_emails') as send_emails: self.command.handle(site_domain_name=self.site.domain, date='2017-09-29') send_emails.assert_called_once_with( self.site, datetime.datetime(2017, 9, 29, tzinfo=pytz.UTC), None) def test_send_emails(self): with patch.multiple( self.command, offsets=(1, 3, 5), enqueue=DEFAULT, ): arg = Mock(name='arg') kwarg = Mock(name='kwarg') self.command.send_emails(arg, kwarg=kwarg) self.assertFalse(arg.called) self.assertFalse(kwarg.called) for offset in self.command.offsets: self.command.enqueue.assert_any_call(offset, arg, kwarg=kwarg)
class TestSendEmailBaseCommand(CacheIsolationTestCase): # lint-amnesty, pylint: disable=missing-class-docstring def setUp(self): # lint-amnesty, pylint: disable=super-method-not-called self.command = SendEmailBaseCommand() self.site = SiteFactory() self.site_config = SiteConfigurationFactory.create(site=self.site) def test_handle(self): with patch.object(self.command, 'send_emails') as send_emails: self.command.handle(site_domain_name=self.site.domain, date='2017-09-29') send_emails.assert_called_once_with( self.site, datetime.datetime(2017, 9, 29, tzinfo=pytz.UTC), None) def test_weeks_option(self): with patch.object(self.command, 'enqueue') as enqueue: self.command.handle(site_domain_name=self.site.domain, date='2017-09-29', weeks=12) self.assertEqual(enqueue.call_count, 12) def test_send_emails(self): with patch.multiple( self.command, offsets=(1, 3, 5), enqueue=DEFAULT, ): arg = Mock(name='arg') kwarg = Mock(name='kwarg') self.command.send_emails(arg, kwarg=kwarg) self.assertFalse(arg.called) self.assertFalse(kwarg.called) for offset in self.command.offsets: self.command.enqueue.assert_any_call(offset, arg, kwarg=kwarg) # lint-amnesty, pylint: disable=no-member
class TestSendEmailBaseCommand(CacheIsolationTestCase): def setUp(self): self.command = SendEmailBaseCommand() def test_init_resolver_class(self): assert self.command.resolver_class is None def test_make_resolver(self): with patch.object(self.command, 'resolver_class') as resolver_class: example_site = SiteFactory(domain='example.com') self.command.make_resolver(site_domain_name='example.com', date='2017-09-29') resolver_class.assert_called_once_with( example_site, datetime.datetime(2017, 9, 29, tzinfo=pytz.UTC)) def test_handle(self): with patch.object(self.command, 'make_resolver') as make_resolver: make_resolver.return_value = 'resolver' with patch.object(self.command, 'send_emails') as send_emails: self.command.handle(date='2017-09-29') make_resolver.assert_called_once_with(date='2017-09-29') send_emails.assert_called_once_with('resolver', date='2017-09-29')
class TestSendEmailBaseCommand(CacheIsolationTestCase): def setUp(self): self.command = SendEmailBaseCommand() def test_init_resolver_class(self): assert self.command.resolver_class is None def test_make_resolver(self): with patch.object(self.command, 'resolver_class') as resolver_class: example_site = SiteFactory(domain='example.com') self.command.make_resolver(site_domain_name='example.com', date='2017-09-29') resolver_class.assert_called_once_with( example_site, datetime.datetime(2017, 9, 29, tzinfo=pytz.UTC) ) def test_handle(self): with patch.object(self.command, 'make_resolver') as make_resolver: make_resolver.return_value = 'resolver' with patch.object(self.command, 'send_emails') as send_emails: self.command.handle(date='2017-09-29') make_resolver.assert_called_once_with(date='2017-09-29') send_emails.assert_called_once_with('resolver', date='2017-09-29')
def setUp(self): self.command = SendEmailBaseCommand() self.site = SiteFactory() self.site_config = SiteConfigurationFactory.create(site=self.site)
def setUp(self): self.command = SendEmailBaseCommand()
def setUp(self): # lint-amnesty, pylint: disable=super-method-not-called self.command = SendEmailBaseCommand() self.site = SiteFactory() self.site_config = SiteConfigurationFactory.create(site=self.site)
def setUp(self): self.command = SendEmailBaseCommand() self.site = SiteFactory() self.site_config = SiteConfigurationFactory.create(site=self.site)
def setUp(self): self.command = SendEmailBaseCommand()