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() 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)