def test(): stubydoo.expect(self.double, 'method').at_most(4).times.\ at_least(2).times self.double.method() self.double.method() self.double.method() self.double.method()
def test_unlinks_key_and_context(self): context = object() expect(self.context_keys.unlink).to_be_called.\ with_args('the key', context).once self.cache_manager.remove('the key', context)
def test_traversing_to_a_unknown_key_redirects(self): response = double(redirect=lambda self, url:None) request = double(response=response) expect(response.redirect).with_args('the original url') cache_keys = zope.component.getUtility(interfaces.ICacheKeys) stub(cache_keys.getURL).with_args('unknown key').\ and_return('the original url') self.cache_traverser.publishTraverse(request, 'unknown key')
def test_no_inline_styles(self): self.configuration.inline_styles = False self.newsletter_attributes.html = \ u'<style>p{color:red}</style><p>Foo</p>' stubydoo.expect(self.message_factory.__call__).\ to_be_called.with_args(string_containing( u'<style>p{color:red}</style></head><body><p>Foo</p>' )) self.newsletter.compile(self.subscriber)
def test_add_adds_subscriber_with_form_data(self): obj = stubydoo.double() obj.id = 'the subscriber id' stubydoo.stub(self.add_form.extractData).\ and_return(('the data', None)) stubydoo.expect(self.add_form.createAndAdd).\ with_args('the data').and_return(obj) self.adder.add('email', 'format', None, None)
def test_send_should_be_able_to_not_fire_event(self): testpoint = stubydoo.double(event_called=lambda x: None) @zope.component.adapter(None, interfaces.INewsletterSentEvent) def handler(object, event): testpoint.event_called() zope.component.provideHandler(handler) stubydoo.expect(testpoint.event_called).to_not_be_called self.mailing.send(self.context, suppress_events=True, mailhost=self.mailhost, subscribers=self.subscribers)
def test_failing_assertion(self): stubydoo.expect(self.double, 'method') self.assertRaises(stubydoo.ExpectationNotSatisfiedError, stubydoo.assert_expectations)
def exceeded(): stubydoo.expect(self.double, 'method').to_not_be_called self.double.method()
def reached(): stubydoo.expect(self.double, 'method').to_not_be_called
def test(): stubydoo.expect(obj, 'method')
def test_always_clears_cache_for_context_before_everything(self): expect(cache_manager.removeAll).with_args(self.subject.context) self.subject.update()
def other_test(): stubydoo.expect(self.double, 'other_method')
def exceeded(): stubydoo.expect(self.double, 'method').twice self.double.method() self.double.method() self.double.method()
def reached(): stubydoo.expect(self.double, 'method').twice self.double.method() self.double.method()
def not_reached(): stubydoo.expect(self.double, 'method').once
def test_links_key_and_context(self): context = object() expect(self.context_keys.link).to_be_called.\ with_args('the key', context) self.cache_manager.add('the key', context, 'value')
def test(): stubydoo.expect(self.double, 'method').exactly(2).times self.double.method()
def test(): stubydoo.expect(self.double, 'method').and_return(value) return self.double.method()
def test(): stubydoo.expect(obj.method)
def test_successful_assertion(self): stubydoo.expect(self.double, 'method') self.double.method() stubydoo.assert_expectations()
def test(): stubydoo.expect(self.double, 'method')
def test_add_should_update_form_after_setting_values_in_request(self): stubydoo.expect(self.add_form.track_update).\ with_args('email', 'format') self.adder.add('email', 'format', None, None)
def test_something(self): stubydoo.expect(self.double, 'method') self.double.method()
def reached(): stubydoo.expect(self.double, 'method').at_most(0).times
def test_remove_all_is_called(self): content = object() expect(self.cache_manager, 'removeAll').with_args(content) html_image_cacher.removeItemsFromCache(content, 'event')
def exceeded(): stubydoo.expect(self.double, 'method').at_most(0).times self.double.method()
def reached(): stubydoo.expect(self.double, 'method').exactly(0).times
def test(): stubydoo.stub(self.double, 'method') stubydoo.expect(self.double, 'method') self.double.method()
def exceeded(): stubydoo.expect(self.double, 'method').exactly(0).times self.double.method()
def test_send_without_specifying_subscribers(self): self.configure_newsletter_from_content_behavior() stubydoo.expect(self.mailhost, 'send').with_args(self.message) self.mailing.send(self.context, mailhost=self.mailhost)