def test_wraps_get_user_as_user_fetcher(self, patch, pyramid_request): get_user = patch('h.groups.services.get_user') svc = groups_factory(None, pyramid_request) svc.user_fetcher('foo') get_user.assert_called_once_with('foo', pyramid_request)
def test_wraps_user_service_as_user_fetcher(self, pyramid_request, user_service): svc = groups_factory(None, pyramid_request) svc.user_fetcher('foo') user_service.fetch.assert_called_once_with('foo')
def test_provides_realtime_publisher_as_publish(self, patch, pyramid_request): pyramid_request.realtime = mock.Mock(spec_set=['publish_user']) session = patch('h.groups.services.session') svc = groups_factory(None, pyramid_request) svc.publish('group-join', 'abc123', 'theresa') session.model.assert_called_once_with(pyramid_request) pyramid_request.realtime.publish_user.assert_called_once_with({ 'type': 'group-join', 'session_model': session.model.return_value, 'userid': 'theresa', 'group': 'abc123', })
def test_provides_request_db_as_session(self, pyramid_request): svc = groups_factory(None, pyramid_request) assert svc.session == pyramid_request.db
def test_returns_groups_service(self, pyramid_request): svc = groups_factory(None, pyramid_request) assert isinstance(svc, GroupsService)