Beispiel #1
0
    def test_register_controller_extensions_without_mail(self):
        from horus.views        import RegisterController
        from horus.interfaces   import IRegisterSchema
        from horus.interfaces   import IRegisterForm
        from horus.interfaces   import IUserClass
        from horus.interfaces   import IUIStrings
        from horus.strings      import UIStringsBase
        from horus.tests.models import User
        from horus.interfaces   import IActivationClass
        from horus.tests.models import Activation
        self.config.registry.registerUtility(Activation, IActivationClass)
        self.config.registry.registerUtility(User, IUserClass)
        self.config.registry.registerUtility(UIStringsBase, IUIStrings)

        self.config.add_route('index', '/')

        request = testing.DummyRequest()

        getUtility = Mock()
        getUtility.return_value = True

        schema = Mock()
        form = Mock()

        self.config.registry.settings['horus.require_activation'] = False
        self.config.registry.registerUtility(schema, IRegisterSchema)
        self.config.registry.registerUtility(form, IRegisterForm)

        with patch('horus.views.get_mailer') as get_mailer:
            RegisterController(request)
            assert not get_mailer.called

        schema.assert_called_once_with()
        assert form.called
    def test_main_loop_no_task(self):
        config = Mock()
        pool_size = 4

        mocked_pool = Mock()
        mocked_pool.free_count = Mock(return_value=pool_size)

        mocked_done_with_processed_tasks = Mock(side_effect=self.main_loop_done_with_processed_tasks)

        mocked_worker = Mock()
        mocked_gevent_queue = Mock()

        mocked_task = Mock()

        mocked_tube = Mock(return_value=mocked_task)
        mocked_tube.take = Mock(return_value=None)

        mocked_tarantool_queue = Mock()
        mocked_tarantool_queue.tube = Mock(return_value=mocked_tube)

        with patch('notification_pusher.tarantool_queue.Queue', Mock(return_value=mocked_tarantool_queue)):
            with patch('notification_pusher.Pool', Mock(return_value=mocked_pool)):
                with patch('notification_pusher.done_with_processed_tasks', mocked_done_with_processed_tasks):
                    with patch('notification_pusher.Greenlet', Mock(return_value=mocked_worker)):
                        with patch('notification_pusher.gevent_queue.Queue', Mock(return_value=mocked_gevent_queue)):
                            notification_pusher.run_application = True
                            main_loop(config)

                            assert not mocked_worker.start.called
                            mocked_done_with_processed_tasks.assert_called_once_with(mocked_gevent_queue)
Beispiel #3
0
class LinkTests(TestCase):

    def setUp(self):
        self.other_page_cls = Mock()
        class TestPage(Page):
            clickme = Link('id=clickme')
            linktopage = Link('id=linktopage', to=self.other_page_cls)
        self.webelement = Mock()
        self.driver = Mock(**{'find_elements.return_value': [self.webelement]})
        set_driver(self.driver)
        self.page = TestPage(assert_is_on_page=False)

    def test_call(self):
        ret = self.page.clickme()
        self.assertIsNone(ret)
        self.webelement.click.assert_called_once_with()

    def test_click(self):
        ret = self.page.clickme.click()
        self.assertIsNone(ret)
        self.webelement.click.assert_called_once_with()

    def test_to_page(self):
        page = self.page.linktopage()
        self.other_page_cls.assert_called_once_with(assert_is_on_page=True)
        self.assertIs(page, self.other_page_cls())

    def test_to_page_without_url(self):
        other_page_cls = Mock(url=None)
        class TestPage(Page):
            linktopage = Link('id=linktopage', to=other_page_cls)
        page = TestPage()
        page.linktopage()
        other_page_cls.assert_called_once_with(assert_is_on_page=False)
    def test_calls_provided_test(self):
        client = fake_juju_client()
        with temp_dir() as juju_home:
            client.env.juju_home = juju_home
            bs_manager = make_bootstrap_manager(client)
            bs_manager.log_dir = os.path.join(juju_home, 'log-dir')
            os.mkdir(bs_manager.log_dir)

            timing = gpr.TimingData(datetime.utcnow(), datetime.utcnow())
            deploy_details = gpr.DeployDetails('test', dict(), timing)
            noop_test = Mock(return_value=deploy_details)

            pprof_collector = Mock()

            with patch.object(gpr, 'dump_performance_metrics_logs',
                              autospec=True):
                with patch.object(gpr, 'generate_reports', autospec=True):
                    with patch.object(
                            gpr, 'PPROFCollector', autospec=True) as p_pc:
                        p_pc.return_value = pprof_collector
                        gpr.run_perfscale_test(
                            noop_test,
                            bs_manager,
                            get_default_args())

            noop_test.assert_called_once_with(
                client, pprof_collector, get_default_args())
    def test_multiple_errbacks(self):
        session = self.make_session()
        pool = session._pools.get.return_value
        connection = Mock(spec=Connection)
        pool.borrow_connection.return_value = (connection, 1)

        query = SimpleStatement("INSERT INFO foo (a, b) VALUES (1, 2)")
        query.retry_policy = Mock()
        query.retry_policy.on_unavailable.return_value = (RetryPolicy.RETHROW, None)
        message = QueryMessage(query=query, consistency_level=ConsistencyLevel.ONE)

        rf = ResponseFuture(session, message, query, 1)
        rf.send_request()

        callback = Mock()
        arg = "positional"
        kwargs = {'one': 1, 'two': 2}
        rf.add_errback(callback, arg, **kwargs)

        callback2 = Mock()
        arg2 = "another"
        kwargs2 = {'three': 3, 'four': 4}
        rf.add_errback(callback2, arg2, **kwargs2)

        expected_exception = Unavailable("message", 1, 2, 3)
        result = Mock(spec=UnavailableErrorMessage, info={'something': 'here'})
        result.to_exception.return_value = expected_exception
        rf._set_result(result)
        self.assertRaises(Exception, rf.result)

        callback.assert_called_once_with(expected_exception, arg, **kwargs)
        callback2.assert_called_once_with(expected_exception, arg2, **kwargs2)
    def test_rmtree_ignore_unlink_rmdir_exception(self):
        dir1_list = ["dir2", "file"]
        empty_list = []
        mock_listdir = Mock()
        mock_listdir.side_effect = [dir1_list, empty_list]

        mock_isdir = Mock()
        mock_isdir.side_effect = [True, False]

        mock_unlink = Mock()
        mock_unlink.side_effect = [OSError]

        mock_rmdir = Mock()
        mock_rmdir.side_effect = [0, OSError]

        mock_islink = Mock()
        mock_islink.return_value = False

        with nested(patch("gluster.gfapi.Volume.listdir", mock_listdir),
                    patch("gluster.gfapi.Volume.isdir", mock_isdir),
                    patch("gluster.gfapi.Volume.islink", mock_islink),
                    patch("gluster.gfapi.Volume.unlink", mock_unlink),
                    patch("gluster.gfapi.Volume.rmdir", mock_rmdir)):
            self.vol.rmtree("dir1", True)
            mock_rmdir.assert_any_call("dir1/dir2")
            mock_unlink.assert_called_once_with("dir1/file")
            mock_rmdir.assert_called_with("dir1")
Beispiel #7
0
 def test_open(self, sleep):
     fn = Mock()
     connection = Mock(url=URL, retry=True)
     fx = retry(ConnectError)(fn)
     fx(connection)
     fn.assert_called_once_with(connection)
     self.assertFalse(sleep.called)
Beispiel #8
0
    def test15_poll_notification(self):
        args = { 'type': ['tabs'],
                 'action': ['poll'],
                 'player_id': [13],
                 'game_id': [20],
                 'modified': [10000000000000000] }

        # Fake poll controlled from the test
        poll = defer.Deferred()
        mock_poll_tabs = Mock()
        mock_poll_tabs.return_value = poll
        orig_service_poll_tabs = self.service.poll_tabs
        self.service.poll_tabs = mock_poll_tabs

        mock_listener = Mock()
        self.service.listen().addCallback(mock_listener)
        self.service.poll(args)
        mock_listener.assert_called_once_with({'player_id': 13, 'type': 'poll_start'})

        mock_listener.reset_mock()
        self.service.listen().addCallback(mock_listener)
        poll.callback(args)
        mock_listener.assert_called_once_with({'player_id': 13, 'type': 'poll_end'})

        self.service.poll_tabs = orig_service_poll_tabs
Beispiel #9
0
    def test_trigger_events(self, mock_from):
        mock_after = Mock()
        mock_before = Mock()
        mock_from.return_value = {'foo': 1}
        ctx = Mock()
        view = Mock(
            request=Mock(action='index'),
            _json_params={'bar': 1},
            context=ctx,
            _silent=False)
        view.index._silent = False
        view.index._event_action = None

        with patch.dict(events.BEFORE_EVENTS, {'index': mock_before}):
            with patch.dict(events.AFTER_EVENTS, {'index': mock_after}):
                with events.trigger_events(view):
                    pass

        mock_after.assert_called_once_with(
            fields={'foo': 1}, model=view.Model, instance=ctx,
            view=view)
        mock_before.assert_called_once_with(
            fields={'foo': 1}, model=view.Model, instance=ctx,
            view=view)
        view.request.registry.notify.assert_has_calls([
            call(mock_before()),
            call(mock_after()),
        ])
        mock_from.assert_called_once_with({'bar': 1}, view.Model)
Beispiel #10
0
def test_run_in_subprocess():
    with patch.multiple('pkglib_testing.cmdline', cPickle=DEFAULT, execnet=DEFAULT) as mocks:
        fn = Mock(__name__='fn')
        res = cmdline.run_in_subprocess(fn, python='sentinel.python')(sentinel.arg, kw=sentinel.kw)
        mocks['execnet'].makegateway.assert_called_once_with('popen//python=sentinel.python')
        gw = mocks['execnet'].makegateway.return_value
        ((remote_fn,), _) = gw.remote_exec.call_args
        chan = gw.remote_exec.return_value
        mocks['cPickle'].dumps.assert_called_with((fn, (sentinel.arg,), {'kw': sentinel.kw}), protocol=0)
        chan.send.assert_called_with(mocks['cPickle'].dumps.return_value)
        chan.receive.assert_has_calls([call(None) for _i in range(gw.remote_exec.call_count)])
        mocks['cPickle'].loads.assert_called_once_with(chan.receive.return_value)
        assert res is mocks['cPickle'].loads.return_value
        chan.close.assert_has_calls([call() for _i in range(gw.remote_exec.call_count)])
        gw.exit.assert_called_once_with()

    with patch('pkglib_util.six.moves.cPickle') as cPickle:
        channel, fn = Mock(), Mock()
        cPickle.loads.return_value = (fn, (sentinel.arg,), {'kw': sentinel.kw})
        remote_fn(channel)
        channel.receive.assert_called_once_with(None)
        cPickle.loads.assert_called_once_with(channel.receive.return_value)
        fn.assert_called_once_with(sentinel.arg, kw=sentinel.kw)
        cPickle.dumps.assert_called_once_with(fn.return_value, protocol=0)
        channel.send.assert_called_once_with(cPickle.dumps.return_value)
Beispiel #11
0
    def test12_player_info(self):
        player_id = 20
        player_name = u"pl\xe1y\u1ebdr"
        player_avatar_url = "http://example.com/test.jpg"
        player_score = 4141
        player_level, _, _ = cardstories.levels.calculate_level(player_score)

        sql = "INSERT INTO players (player_id, score) VALUES (%d, %d)"
        c = self.db.cursor()
        c.execute(sql % (player_id, player_score))
        self.db.commit()

        # Fake calls to auth module
        default_get_player_name = self.service.auth.get_player_name
        fake_get_player_name = Mock(return_value=player_name)
        self.service.auth.get_player_name = fake_get_player_name

        default_get_player_avatar_url = self.service.auth.get_player_avatar_url
        fake_get_player_avatar_url = Mock(return_value=player_avatar_url)
        self.service.auth.get_player_avatar_url = fake_get_player_avatar_url

        players_info = yield self.service.player_info({'type': 'player_info', 'player_id': [player_id]})
        fake_get_player_name.assert_called_once_with(player_id)
        fake_get_player_avatar_url.assert_called_once_with(player_id)

        self.assertEquals(players_info, [{ 'type': 'players_info',
                                           str(player_id): {'name': player_name,
                                                            'avatar_url': player_avatar_url,
                                                            'level': player_level}
                                         }])

        self.service.auth.get_player_name = default_get_player_name
        self.service.auth.get_player_avatar_url = default_get_player_avatar_url
Beispiel #12
0
    def test_accept(self):
        rmock = Mock()
        rmock.return_value = sentinel.msg

        cacmock = Mock()
        transport = Mock()

        self.ch.recv = rmock
        self.ch._recv_queue.await_n = MagicMock()
        self.ch._create_accepted_channel = cacmock
        self.ch.on_channel_open(transport)
        self.ch._fsm.current_state = self.ch.S_ACTIVE
        self.ch._consuming = True

        retch = self.ch.accept()
        self.assertEquals(self.ch._fsm.current_state, self.ch.S_ACCEPTED)
        cacmock.assert_called_once_with(transport, [sentinel.msg])
        retch._recv_queue.put.assert_called_once_with(sentinel.msg)

        # we've mocked all the working machinery of accept's return etc, so we must manually exit accept
        # as if we've ack'd/reject'd
        self.ch.exit_accept()

        self.assertEquals(self.ch._fsm.current_state, self.ch.S_ACTIVE)
        self.assertTrue(self.ch._consuming)
Beispiel #13
0
 def test_exception_request_handlers(self, f):
     ex = wac.requests.HTTPError()
     ex.response = Mock()
     ex.response.status_code = 402
     ex.response.content = (
         '{"status": "Bad Request", "status_code": '
         '"400", "description": "Invalid field \'your mom\' -- make '
         'sure its your dad too", "additional": "nothing personal"}')
     ex.response.headers = {
         'Content-Type': 'application/json',
     }
     f.__name__ = 'post'
     f.side_effect = ex
     before_request = Mock()
     after_request = Mock()
     with self.cli:
         self.cli.config.root_url = '/test'
         self.cli.config.keep_alive = False
         self.cli.config.before_request.append(before_request)
         self.cli.config.after_request.append(after_request)
         with self.assertRaises(wac.Error) as ex_ctx:
             self.cli.post('/a/post/w/hooks', data={'hi': 'ya'})
     self.assertEqual(ex_ctx.exception.status_code, 402)
     self.assertEqual(ex_ctx.exception.additional, 'nothing personal')
     before_request.assert_called_once_with(
         'POST',
         '/test/a/post/w/hooks',
         {'headers': {'Content-Type': 'application/json'},
          'allow_redirects': False,
          'data': '{"hi": "ya"}',
          }
     )
     after_request.assert_called_once_with(ex.response)
Beispiel #14
0
    def test_manual_execute_with_ids_ignored_while_in_execute(self):
        waiter = Event()

        long_execute_waiter = Event()

        # noinspection PyUnusedLocal
        def execute(*args, **kwargs):
            waiter.set()
            long_execute_waiter.wait(1)
            self.assertTrue(long_execute_waiter.is_set)

        execute_mock = Mock(side_effect=execute)
        self.trackers_manager.execute = execute_mock

        self.create_runner(interval=1)
        self.engine_runner.execute(None)
        waiter.wait(0.3)
        waiter.clear()
        ids = [1, 2, 3]
        self.engine_runner.execute(ids)
        long_execute_waiter.set()
        waiter.wait(0.3)
        self.assertTrue(waiter.is_set)

        self.stop_runner()

        execute_mock.assert_called_once_with(ANY, None)
Beispiel #15
0
    def test_new_mode_callback(self):
        """Create a Controller object, call on_new_mode_online method and
        check that the callback fires when set_composite_mode is called
        """
        self.setup_server()
        self.setup_controller()

        self.log.info("setting callback")
        test_cb = Mock(side_effect=self.quit_mainloop)
        self.controller.on_new_mode_online(test_cb)

        self.log.info("starting test-sources")
        self.setup_video_sources(count=2)

        self.log.info("waiting for initial callback with default-mode"
                      "COMPOSITE_DUAL_EQUAL")
        self.run_mainloop(timeout=5)
        test_cb.assert_called_once_with(Controller.COMPOSITE_DUAL_EQUAL)
        test_cb.reset_mock()

        self.log.info("setting new composite mode COMPOSITE_NONE")
        assert self.controller.set_composite_mode(Controller.COMPOSITE_NONE)
        self.run_mainloop(timeout=5)

        self.log.info("waiting for callback with new mode COMPOSITE_NONE")
        test_cb.assert_called_once_with(Controller.COMPOSITE_NONE)
Beispiel #16
0
 def test_connect_default_type(self):
     transport = Mock()
     with patch.dict(pyeapi.client.TRANSPORTS, {'https': transport}):
         pyeapi.client.connect()
         kwargs = dict(host='localhost', username='admin', password='',
                       port=None)
         transport.assert_called_once_with(**kwargs)
 def test_set_logging_err(self):
     v = Volume("host", "vol")
     v.fs = 12345
     _m_set_logging = Mock(return_value=-1)
     with patch("gluster.gfapi.api.glfs_set_logging", _m_set_logging):
         self.assertRaises(LibgfapiException, v.set_logging, "/dev/null", 7)
         _m_set_logging.assert_called_once_with(v.fs, None, 7)
Beispiel #18
0
 def test_kwarg_pass_through_no_kwargs(self):
     call_func = Mock()
     data = sentinel.data
     axis = sentinel.axis
     aggregator = Aggregator('', call_func)
     aggregator.aggregate(data, axis)
     call_func.assert_called_once_with(data, axis=axis)
    def test_update(self, include_prerelease, is_started, start_interval, enabled, interval, start_called, stop_called):
        checker = NewVersionChecker(False)

        def start_side_effect(i):
            checker.interval = i

        start_mock = Mock(side_effect=start_side_effect)
        stop_mock = Mock()
        is_started_mock = Mock(return_value=is_started)

        checker.interval = start_interval
        checker.start = start_mock
        checker.stop = stop_mock
        checker.is_started = is_started_mock

        checker.update(include_prerelease, enabled, interval)

        self.assertEqual(checker.interval, interval)
        self.assertEqual(checker.include_prereleases, include_prerelease)
        if start_called:
            start_mock.assert_called_once_with(interval)
        else:
            start_mock.assert_not_called()

        if stop_called:
            stop_mock.assert_called_once()
        else:
            stop_mock.assert_not_called()
Beispiel #20
0
 def test_mdtol_intercept(self):
     call_func = Mock()
     data = sentinel.data
     axis = sentinel.axis
     aggregator = Aggregator('', call_func)
     aggregator.aggregate(data, axis, wibble='wobble', mdtol=0.8)
     call_func.assert_called_once_with(data, axis=axis, wibble='wobble')
    def test_create_report_graph_returns_base_file_path(self):
        """The returned filepath should just be the basename."""
        generator = Mock()
        start = 0000
        end = 9999
        file_list = ['example.rrd']
        rrd_dir = '/foo'
        output_file = '/bar/test.png'
        output_file_base = 'test.png'
        graph_period = '0'

        with patch.object(
                gpr.os, 'listdir',
                autospec=True, return_value=file_list) as m_list:
            with patch.object(
                    gpr, 'get_duration_points',
                    autospec=True, return_value=(start, end)) as m_gdp:
                self.assertEqual(
                    output_file_base,
                    gpr.create_report_graph(
                        rrd_dir, output_file, generator, graph_period)
                )
        m_gdp.assert_called_once_with('/foo/example.rrd', graph_period)
        m_list.assert_called_once_with(rrd_dir)
        generator.assert_called_once_with(
            start, end, rrd_dir, output_file)
Beispiel #22
0
 def test_kwarg_pass_through_no_kwargs(self):
     lazy_func = Mock()
     data = sentinel.data
     axis = sentinel.axis
     aggregator = Aggregator('', None, lazy_func=lazy_func)
     aggregator.lazy_aggregate(data, axis)
     lazy_func.assert_called_once_with(data, axis)
Beispiel #23
0
    def file_type_test(self,
                       bucket_method,
                       test_file,
                       content_type,
                       resized_size):
        bucket = Mock()
        bucket_method.return_value = bucket
        new_key = Mock()
        bucket.new_key.return_value = new_key
        image_handler = ImageHandler(filename=test_file)
        truck = ImageTruck.new_from_file(test_file)
        session = Client().session()
        image = ImageTable(filename='badcafe')
        session.add(image)
        session.flush()
        after_upload = Mock()

        ResizeImage._resize_image(image,
                                  image_handler,
                                  truck,
                                  'thumbnail',
                                  after_upload)

        new_key.set_metadata.assert_called_with('Content-Type', content_type)
        resized_contents = new_key.set_contents_from_string.call_args[0][0]

        image_handler = ImageHandler(blob=resized_contents)
        eq_(image_handler.size, resized_size)

        after_upload.assert_called_once_with('thumbnail')
Beispiel #24
0
 def test_put(self):
     func = Mock()
     value = "test_value"
     a = Attribute("test", Mock())
     a.set_put_function(func)
     a.put(value)
     func.assert_called_once_with(value)
    def test_add_callbacks(self):
        session = self.make_session()
        query = SimpleStatement("INSERT INFO foo (a, b) VALUES (1, 2)")
        query.retry_policy = Mock()
        query.retry_policy.on_unavailable.return_value = (RetryPolicy.RETHROW, None)
        message = QueryMessage(query=query, consistency_level=ConsistencyLevel.ONE)

        # test errback
        rf = ResponseFuture(session, message, query, 1)
        rf.send_request()

        rf.add_callbacks(
            callback=self.assertEqual, callback_args=([{'col': 'val'}],),
            errback=self.assertIsInstance, errback_args=(Exception,))

        result = Mock(spec=UnavailableErrorMessage, info={})
        rf._set_result(result)
        self.assertRaises(Exception, rf.result)

        # test callback
        rf = ResponseFuture(session, message, query, 1)
        rf.send_request()

        callback = Mock()
        expected_result = [{'col': 'val'}]
        arg = "positional"
        kwargs = {'one': 1, 'two': 2}
        rf.add_callbacks(
            callback=callback, callback_args=(arg,), callback_kwargs=kwargs,
            errback=self.assertIsInstance, errback_args=(Exception,))

        rf._set_result(self.make_mock_response(expected_result))
        self.assertEqual(rf.result(), expected_result)

        callback.assert_called_once_with(expected_result, arg, **kwargs)
Beispiel #26
0
 def test_injects_match_groups_to_app(self):
     app = Mock(name='app')
     r = wsgi.PathRouter(
         ('{foo}/{bar}', lambda foo, bar: app(foo, bar)),
     )
     self.assertIs(r(self.context, 'oof/rab'), app.return_value)
     app.assert_called_once_with('oof', 'rab')
Beispiel #27
0
 def test_extract_from_files_callback_works(self):
     """extract_from_files should call our callback"""
     testfile = ('templates/even_more_lang_files.html',)
     callback = Mock()
     next(extract_from_files(testfile, callback=callback,
                             method_map=METHODS), None)
     callback.assert_called_once_with(testfile[0], METHODS[0][1], ANY)
def test_dependencer(Wheel):
    "Dependencer#handle() should emit the signal dependency_found when scanning a new package"

    # Given that I have the depencencer service
    callback = Mock()
    dependencer = Dependencer()
    dependencer.connect('dependency_found', callback)

    # And that the package to test the service will have the following
    # dependencies:
    Wheel.return_value = Mock(metadata=Mock(dependencies={
        'install': ['forbiddenfruit (0.1.1)'],
        'extras': {},
    }))

    # When I queue a package and a sentinel and then call the worker
    dependencer.queue('tests', requirement='sure', wheel='forbiddenfruit-0.1-cp27.whl')
    dependencer.queue(None)
    dependencer._worker()

    # Than I see that the signal was called for the dependency with the right
    # parameters
    callback.assert_called_once_with(
        'dependencer',
        requirement='forbiddenfruit (0.1.1)',
        dependency_of='sure')
Beispiel #29
0
 def test_to_page_without_url(self):
     other_page_cls = Mock(url=None)
     class TestPage(Page):
         linktopage = Link('id=linktopage', to=other_page_cls)
     page = TestPage()
     page.linktopage()
     other_page_cls.assert_called_once_with(assert_is_on_page=False)
Beispiel #30
0
def test_subscriber_predicate(config):
    """Test that the ``asset_request`` subscriber predicate.

    It should correctly match asset requests when its value is ``True``,
    and other requests when ``False``.
    """
    config.include(assets)

    mock1 = Mock()
    mock2 = Mock()

    config.add_subscriber(mock1, DummyEvent, asset_request=False)
    config.add_subscriber(mock2, DummyEvent, asset_request=True)

    request1 = DummyRequest('/')
    request1.matched_route = None

    pattern = config.get_webassets_env().url + '*subpath'
    request2 = DummyRequest(config.get_webassets_env().url + '/t.png')
    request2.matched_route = Route('__' + pattern, pattern)

    event1 = DummyEvent(request1)
    event2 = DummyEvent(request2)

    config.registry.notify(event1)
    config.registry.notify(event2)

    mock1.assert_called_once_with(event1)
    mock2.assert_called_once_with(event2)