Exemplo n.º 1
0
 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)
Exemplo n.º 5
0
    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_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)
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
    def test_failing_assertion(self):
        stubydoo.expect(self.double, 'method')

        self.assertRaises(stubydoo.ExpectationNotSatisfiedError,
                          stubydoo.assert_expectations)
Exemplo n.º 9
0
 def exceeded():
     stubydoo.expect(self.double, 'method').to_not_be_called
     self.double.method()
Exemplo n.º 10
0
 def reached():
     stubydoo.expect(self.double, 'method').to_not_be_called
Exemplo n.º 11
0
 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()
Exemplo n.º 13
0
 def other_test():
     stubydoo.expect(self.double, 'other_method')
Exemplo n.º 14
0
 def exceeded():
     stubydoo.expect(self.double, 'method').twice
     self.double.method()
     self.double.method()
     self.double.method()
Exemplo n.º 15
0
 def reached():
     stubydoo.expect(self.double, 'method').twice
     self.double.method()
     self.double.method()
Exemplo n.º 16
0
 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')
Exemplo n.º 18
0
 def test():
     stubydoo.expect(self.double, 'method').exactly(2).times
     self.double.method()
Exemplo n.º 19
0
 def test():
     stubydoo.expect(self.double, 'method').and_return(value)
     return self.double.method()
Exemplo n.º 20
0
 def test():
     stubydoo.expect(obj.method)
Exemplo n.º 21
0
    def test_successful_assertion(self):
        stubydoo.expect(self.double, 'method')
        self.double.method()

        stubydoo.assert_expectations()
Exemplo n.º 22
0
 def test():
     stubydoo.expect(self.double, 'method')
Exemplo n.º 23
0
 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)
Exemplo n.º 24
0
 def test_something(self):
     stubydoo.expect(self.double, 'method')
     self.double.method()
Exemplo n.º 25
0
 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')
Exemplo n.º 27
0
 def exceeded():
     stubydoo.expect(self.double, 'method').at_most(0).times
     self.double.method()
Exemplo n.º 28
0
 def reached():
     stubydoo.expect(self.double, 'method').exactly(0).times
Exemplo n.º 29
0
 def test():
     stubydoo.stub(self.double, 'method')
     stubydoo.expect(self.double, 'method')
     self.double.method()
Exemplo n.º 30
0
 def exceeded():
     stubydoo.expect(self.double, 'method').exactly(0).times
     self.double.method()
Exemplo n.º 31
0
    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)