How to use dispatcher method in localstack

Best Python code snippet using localstack_python

dispatcher_test.py

Source:dispatcher_test.py Github

copy

Full Screen

...155 def get_instance_address(self, instance):156 if instance == 'invalid':157 raise request_info.InvalidInstanceIdError()158 return '%s:%s' % (self._host, int(instance) + 1000)159def _make_dispatcher(app_config):160 """Make a new dispatcher with the given ApplicationConfigurationStub."""161 return dispatcher.Dispatcher(162 app_config,163 'localhost',164 1,165 'gmail.com',166 1,167 php_config=None,168 python_config=None,169 java_config=None,170 go_config=None,171 custom_config=None,172 cloud_sql_config=None,173 vm_config=None,174 module_to_max_instances={},175 use_mtime_file_watcher=False,176 automatic_restart=True,177 allow_skipped_files=False,178 module_to_threadsafe_override={},179 external_port=None)180class DispatcherQuitWithoutStartTest(unittest.TestCase):181 def test_quit_without_start(self):182 """Test that calling quit on a dispatcher without calling start is safe."""183 app_config = ApplicationConfigurationStub(MODULE_CONFIGURATIONS)184 unstarted_dispatcher = _make_dispatcher(app_config)185 unstarted_dispatcher.quit()186class DispatcherTest(unittest.TestCase):187 def setUp(self):188 self.mox = mox.Mox()189 api_server.test_setup_stubs()190 self.dispatch_config = DispatchConfigurationStub()191 app_config = ApplicationConfigurationStub(MODULE_CONFIGURATIONS)192 self.dispatcher = _make_dispatcher(app_config)193 self.module1 = AutoScalingModuleFacade(app_config.modules[0],194 balanced_port=1,195 host='localhost')196 self.module2 = ManualScalingModuleFacade(app_config.modules[0],197 balanced_port=2,198 host='localhost')199 self.module3 = ManualScalingModuleFacade(app_config.modules[0],200 balanced_port=3,201 host='0.0.0.0')202 self.mox.StubOutWithMock(self.dispatcher, '_create_module')203 self.dispatcher._create_module(app_config.modules[0], 1).AndReturn(204 (self.module1, 2))205 self.dispatcher._create_module(app_config.modules[1], 2).AndReturn(206 (self.module2, 3))207 self.dispatcher._create_module(app_config.modules[2], 3).AndReturn(208 (self.module3, 4))209 self.mox.ReplayAll()210 self.dispatcher.start('localhost', 12345, object())211 app_config.dispatch = self.dispatch_config212 self.mox.VerifyAll()213 self.mox.StubOutWithMock(module.Module, 'build_request_environ')214 def tearDown(self):215 self.dispatcher.quit()216 self.mox.UnsetStubs()217 def test_get_module_names(self):218 self.assertItemsEqual(['default', 'other', 'another'],219 self.dispatcher.get_module_names())220 def test_get_hostname(self):221 self.assertEqual('localhost:1',222 self.dispatcher.get_hostname('default', 'version'))223 self.assertEqual('localhost:2',224 self.dispatcher.get_hostname('other', 'version2'))225 self.assertRaises(request_info.VersionDoesNotExistError,226 self.dispatcher.get_hostname, 'default', 'fake')227 self.assertRaises(request_info.NotSupportedWithAutoScalingError,228 self.dispatcher.get_hostname, 'default', 'version', '0')229 self.assertEqual('localhost:1000',230 self.dispatcher.get_hostname('other', 'version2', '0'))231 self.assertRaises(request_info.InvalidInstanceIdError,232 self.dispatcher.get_hostname, 'other', 'version2',233 'invalid')234 self.assertRaises(request_info.ModuleDoesNotExistError,235 self.dispatcher.get_hostname,236 'nomodule',237 'version2',238 None)239 self.assertEqual('%s:3' % socket.gethostname(),240 self.dispatcher.get_hostname('another', 'version3'))241 self.assertEqual(242 '%s:1000' % socket.gethostname(),243 self.dispatcher.get_hostname('another', 'version3', '0'))244 def test_get_module_by_name(self):245 self.assertEqual(self.module1,246 self.dispatcher.get_module_by_name('default'))247 self.assertEqual(self.module2,248 self.dispatcher.get_module_by_name('other'))249 self.assertRaises(request_info.ModuleDoesNotExistError,250 self.dispatcher.get_module_by_name, 'fake')251 def test_get_versions(self):252 self.assertEqual(['version'], self.dispatcher.get_versions('default'))253 self.assertEqual(['version2'], self.dispatcher.get_versions('other'))254 self.assertRaises(request_info.ModuleDoesNotExistError,255 self.dispatcher.get_versions, 'fake')256 def test_get_default_version(self):257 self.assertEqual('version', self.dispatcher.get_default_version('default'))258 self.assertEqual('version2', self.dispatcher.get_default_version('other'))259 self.assertRaises(request_info.ModuleDoesNotExistError,260 self.dispatcher.get_default_version, 'fake')261 def test_add_event(self):262 self.mox.StubOutWithMock(scheduled_executor.ScheduledExecutor, 'add_event')263 runnable = object()264 scheduled_executor.ScheduledExecutor.add_event(runnable, 123, ('foo',265 'bar'))266 scheduled_executor.ScheduledExecutor.add_event(runnable, 124, None)267 self.mox.ReplayAll()268 self.dispatcher.add_event(runnable, 123, 'foo', 'bar')269 self.dispatcher.add_event(runnable, 124)270 self.mox.VerifyAll()271 def test_update_event(self):272 self.mox.StubOutWithMock(scheduled_executor.ScheduledExecutor,273 'update_event')274 scheduled_executor.ScheduledExecutor.update_event(123, ('foo', 'bar'))275 self.mox.ReplayAll()276 self.dispatcher.update_event(123, 'foo', 'bar')277 self.mox.VerifyAll()278 def test_add_async_request(self):279 dummy_environ = object()280 self.mox.StubOutWithMock(dispatcher._THREAD_POOL, 'submit')281 self.dispatcher._module_name_to_module['default'].build_request_environ(282 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],283 'body', '1.2.3.4', 1).AndReturn(284 dummy_environ)285 dispatcher._THREAD_POOL.submit(286 self.dispatcher._handle_request, dummy_environ, mox.IgnoreArg(),287 self.dispatcher._module_name_to_module['default'],288 None, catch_and_log_exceptions=True)289 self.mox.ReplayAll()290 self.dispatcher.add_async_request(291 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],292 'body', '1.2.3.4')293 self.mox.VerifyAll()294 def test_add_async_request_specific_module(self):295 dummy_environ = object()296 self.mox.StubOutWithMock(dispatcher._THREAD_POOL, 'submit')297 self.dispatcher._module_name_to_module['other'].build_request_environ(298 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],299 'body', '1.2.3.4', 2).AndReturn(300 dummy_environ)301 dispatcher._THREAD_POOL.submit(302 self.dispatcher._handle_request, dummy_environ, mox.IgnoreArg(),303 self.dispatcher._module_name_to_module['other'],304 None, catch_and_log_exceptions=True)305 self.mox.ReplayAll()306 self.dispatcher.add_async_request(307 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],308 'body', '1.2.3.4', module_name='other')309 self.mox.VerifyAll()310 def test_add_async_request_soft_routing(self):311 """Tests add_async_request with soft routing."""312 dummy_environ = object()313 self.mox.StubOutWithMock(dispatcher._THREAD_POOL, 'submit')314 self.dispatcher._module_name_to_module['default'].build_request_environ(315 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],316 'body', '1.2.3.4', 1).AndReturn(317 dummy_environ)318 dispatcher._THREAD_POOL.submit(319 self.dispatcher._handle_request, dummy_environ, mox.IgnoreArg(),320 self.dispatcher._module_name_to_module['default'],321 None, catch_and_log_exceptions=True)322 self.mox.ReplayAll()323 self.dispatcher.add_async_request(324 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],325 'body', '1.2.3.4', module_name='nomodule')326 self.mox.VerifyAll()327 def test_add_request(self):328 dummy_environ = object()329 self.mox.StubOutWithMock(self.dispatcher, '_resolve_target')330 self.mox.StubOutWithMock(self.dispatcher, '_handle_request')331 self.dispatcher._resolve_target(None, '/foo').AndReturn(332 (self.dispatcher._module_name_to_module['default'], None))333 self.dispatcher._module_name_to_module['default'].build_request_environ(334 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],335 'body', '1.2.3.4', 1, fake_login=True).AndReturn(336 dummy_environ)337 self.dispatcher._handle_request(338 dummy_environ, mox.IgnoreArg(),339 self.dispatcher._module_name_to_module['default'],340 None).AndReturn(['Hello World'])341 self.mox.ReplayAll()342 response = self.dispatcher.add_request(343 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],344 'body', '1.2.3.4', fake_login=True)345 self.mox.VerifyAll()346 self.assertEqual('Hello World', response.content)347 def test_add_request_soft_routing(self):348 """Tests soft routing to the default module."""349 dummy_environ = object()350 self.mox.StubOutWithMock(self.dispatcher, '_handle_request')351 self.dispatcher._module_name_to_module['default'].build_request_environ(352 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],353 'body', '1.2.3.4', 1, fake_login=True).AndReturn(354 dummy_environ)355 self.dispatcher._handle_request(356 dummy_environ, mox.IgnoreArg(),357 self.dispatcher._module_name_to_module['default'],358 None).AndReturn(['Hello World'])359 self.mox.ReplayAll()360 response = self.dispatcher.add_request(361 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],362 'body', '1.2.3.4', fake_login=True, module_name='nomodule')363 self.mox.VerifyAll()364 self.assertEqual('Hello World', response.content)365 def test_add_request_merged_response(self):366 """Tests handlers which return side-effcting generators."""367 dummy_environ = object()368 self.mox.StubOutWithMock(self.dispatcher, '_handle_request')369 self.dispatcher._module_name_to_module['default'].build_request_environ(370 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],371 'body', '1.2.3.4', 1, fake_login=True).AndReturn(372 dummy_environ)373 start_response_ref = []374 def capture_start_response(unused_env, start_response, unused_module,375 unused_inst):376 start_response_ref.append(start_response)377 def side_effecting_handler():378 start_response_ref[0]('200 OK', [('Content-Type', 'text/plain')])379 yield 'Hello World'380 mock = self.dispatcher._handle_request(381 dummy_environ, mox.IgnoreArg(),382 self.dispatcher._module_name_to_module['default'],383 None)384 mock = mock.WithSideEffects(capture_start_response)385 mock = mock.AndReturn(side_effecting_handler())386 self.mox.ReplayAll()387 response = self.dispatcher.add_request(388 'PUT', '/foo?bar=baz', [('Header', 'Value'), ('Other', 'Values')],389 'body', '1.2.3.4', fake_login=True, module_name='nomodule')390 self.mox.VerifyAll()391 self.assertEqual('200 OK', response.status)392 self.assertEqual([('Content-Type', 'text/plain')], response.headers)393 self.assertEqual('Hello World', response.content)394 def test_handle_request(self):395 start_response = object()396 servr = self.dispatcher._module_name_to_module['other']397 self.mox.StubOutWithMock(servr, '_handle_request')398 servr._handle_request({'foo': 'bar'}, start_response, inst=None,399 request_type=3).AndReturn(['body'])400 self.mox.ReplayAll()401 self.dispatcher._handle_request({'foo': 'bar'}, start_response, servr, None,402 request_type=3)403 self.mox.VerifyAll()404 def test_handle_request_reraise_exception(self):405 start_response = object()406 servr = self.dispatcher._module_name_to_module['other']407 self.mox.StubOutWithMock(servr, '_handle_request')408 servr._handle_request({'foo': 'bar'}, start_response).AndRaise(Exception)409 self.mox.ReplayAll()410 self.assertRaises(Exception, self.dispatcher._handle_request,411 {'foo': 'bar'}, start_response, servr, None)412 self.mox.VerifyAll()413 def test_handle_request_log_exception(self):414 start_response = object()415 servr = self.dispatcher._module_name_to_module['other']416 self.mox.StubOutWithMock(servr, '_handle_request')417 self.mox.StubOutWithMock(logging, 'exception')418 servr._handle_request({'foo': 'bar'}, start_response).AndRaise(Exception)419 logging.exception('Internal error while handling request.')420 self.mox.ReplayAll()421 self.dispatcher._handle_request({'foo': 'bar'}, start_response, servr, None,422 catch_and_log_exceptions=True)423 self.mox.VerifyAll()424 def test_call(self):425 self.mox.StubOutWithMock(self.dispatcher, '_module_for_request')426 self.mox.StubOutWithMock(self.dispatcher, '_handle_request')427 servr = object()428 environ = {'PATH_INFO': '/foo', 'QUERY_STRING': 'bar=baz'}429 start_response = object()430 self.dispatcher._module_for_request('/foo').AndReturn(servr)431 self.dispatcher._handle_request(environ, start_response, servr)432 self.mox.ReplayAll()433 self.dispatcher(environ, start_response)434 self.mox.VerifyAll()435 def test_module_for_request(self):436 class FakeDict(dict):437 def __contains__(self, key):438 return True439 def __getitem__(self, key):440 return key441 self.dispatcher._module_name_to_module = FakeDict()442 self.dispatch_config.dispatch = [443 (dispatchinfo.ParsedURL('*/path'), '1'),444 (dispatchinfo.ParsedURL('*/other_path/*'), '2'),445 (dispatchinfo.ParsedURL('*/other_path/'), '3'),446 (dispatchinfo.ParsedURL('*/other_path'), '3'),447 ]...

Full Screen

Full Screen

cpp_generator_templates.py

Source:cpp_generator_templates.py Github

copy

Full Screen

1#!/usr/bin/env python2#3# Copyright (c) 2014-2018 Apple Inc. All rights reserved.4# Copyright (c) 2014 University of Washington. All rights reserved.5#6# Redistribution and use in source and binary forms, with or without7# modification, are permitted provided that the following conditions8# are met:9# 1. Redistributions of source code must retain the above copyright10# notice, this list of conditions and the following disclaimer.11# 2. Redistributions in binary form must reproduce the above copyright12# notice, this list of conditions and the following disclaimer in the13# documentation and/or other materials provided with the distribution.14#15# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''16# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,17# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR18# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS19# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF25# THE POSSIBILITY OF SUCH DAMAGE.26# Generator templates, which can be filled with string.Template.27# Following are classes that fill the templates from the typechecked model.28class CppGeneratorTemplates:29 HeaderPrelude = (30 """#pragma once31${includes}32namespace Inspector {33${typedefs}""")34 HeaderPostlude = (35 """} // namespace Inspector""")36 ImplementationPrelude = (37 """#include "config.h"38#include ${primaryInclude}39${secondaryIncludes}40namespace Inspector {""")41 ImplementationPostlude = (42 """} // namespace Inspector43""")44 AlternateDispatchersHeaderPrelude = (45 """#pragma once46#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)47${includes}48namespace Inspector {49class AlternateBackendDispatcher {50public:51 void setBackendDispatcher(RefPtr<BackendDispatcher>&& dispatcher) { m_backendDispatcher = WTFMove(dispatcher); }52 BackendDispatcher* backendDispatcher() const { return m_backendDispatcher.get(); }53private:54 RefPtr<BackendDispatcher> m_backendDispatcher;55};56""")57 AlternateDispatchersHeaderPostlude = (58 """} // namespace Inspector59#endif // ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)""")60 AlternateBackendDispatcherHeaderDomainHandlerInterfaceDeclaration = (61 """class Alternate${domainName}BackendDispatcher : public AlternateBackendDispatcher {62public:63 virtual ~Alternate${domainName}BackendDispatcher() { }64${commandDeclarations}65};""")66 BackendDispatcherHeaderDomainHandlerDeclaration = (67 """${classAndExportMacro} ${domainName}BackendDispatcherHandler {68public:69${commandDeclarations}70protected:71 virtual ~${domainName}BackendDispatcherHandler();72};""")73 BackendDispatcherHeaderDomainDispatcherDeclaration = (74 """${classAndExportMacro} ${domainName}BackendDispatcher final : public SupplementalBackendDispatcher {75public:76 static Ref<${domainName}BackendDispatcher> create(BackendDispatcher&, ${domainName}BackendDispatcherHandler*);77 void dispatch(long requestId, const String& method, Ref<JSON::Object>&& message) override;78${commandDeclarations}79private:80 ${domainName}BackendDispatcher(BackendDispatcher&, ${domainName}BackendDispatcherHandler*);81 ${domainName}BackendDispatcherHandler* m_agent { nullptr };82};""")83 BackendDispatcherHeaderDomainDispatcherAlternatesDeclaration = (84 """#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)85public:86 void setAlternateDispatcher(Alternate${domainName}BackendDispatcher* alternateDispatcher) { m_alternateDispatcher = alternateDispatcher; }87private:88 Alternate${domainName}BackendDispatcher* m_alternateDispatcher { nullptr };89#endif""")90 BackendDispatcherHeaderAsyncCommandDeclaration = (91 """ ${classAndExportMacro} ${callbackName} : public BackendDispatcher::CallbackBase {92 public:93 ${callbackName}(Ref<BackendDispatcher>&&, int id);94 void sendSuccess(${outParameters});95 };96 virtual void ${commandName}(${inParameters}) = 0;""")97 BackendDispatcherImplementationSmallSwitch = (98 """void ${domainName}BackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message)99{100 Ref<${domainName}BackendDispatcher> protect(*this);101 RefPtr<JSON::Object> parameters;102 message->getObject("params"_s, parameters);103${dispatchCases}104 else105 m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'${domainName}." + method + "' was not found");106}""")107 BackendDispatcherImplementationLargeSwitch = (108"""void ${domainName}BackendDispatcher::dispatch(long requestId, const String& method, Ref<JSON::Object>&& message)109{110 Ref<${domainName}BackendDispatcher> protect(*this);111 RefPtr<JSON::Object> parameters;112 message->getObject("params"_s, parameters);113 typedef void (${domainName}BackendDispatcher::*CallHandler)(long requestId, RefPtr<JSON::Object>&& message);114 typedef HashMap<String, CallHandler> DispatchMap;115 static NeverDestroyed<DispatchMap> dispatchMap;116 if (dispatchMap.get().isEmpty()) {117 static const struct MethodTable {118 const char* name;119 CallHandler handler;120 } commands[] = {121${dispatchCases}122 };123 size_t length = WTF_ARRAY_LENGTH(commands);124 for (size_t i = 0; i < length; ++i)125 dispatchMap.get().add(commands[i].name, commands[i].handler);126 }127 auto findResult = dispatchMap.get().find(method);128 if (findResult == dispatchMap.get().end()) {129 m_backendDispatcher->reportProtocolError(BackendDispatcher::MethodNotFound, "'${domainName}." + method + "' was not found");130 return;131 }132 ((*this).*findResult->value)(requestId, WTFMove(parameters));133}""")134 BackendDispatcherImplementationDomainConstructor = (135 """Ref<${domainName}BackendDispatcher> ${domainName}BackendDispatcher::create(BackendDispatcher& backendDispatcher, ${domainName}BackendDispatcherHandler* agent)136{137 return adoptRef(*new ${domainName}BackendDispatcher(backendDispatcher, agent));138}139${domainName}BackendDispatcher::${domainName}BackendDispatcher(BackendDispatcher& backendDispatcher, ${domainName}BackendDispatcherHandler* agent)140 : SupplementalBackendDispatcher(backendDispatcher)141 , m_agent(agent)142{143 m_backendDispatcher->registerDispatcherForDomain("${domainName}"_s, this);144}""")145 BackendDispatcherImplementationPrepareCommandArguments = (146"""${inParameterDeclarations}147 if (m_backendDispatcher->hasProtocolErrors()) {148 m_backendDispatcher->reportProtocolError(BackendDispatcher::InvalidParams, "Some arguments of method \'${domainName}.${commandName}\' can't be processed"_s);149 return;150 }151""")152 BackendDispatcherImplementationAsyncCommand = (153"""${domainName}BackendDispatcherHandler::${callbackName}::${callbackName}(Ref<BackendDispatcher>&& backendDispatcher, int id) : BackendDispatcher::CallbackBase(WTFMove(backendDispatcher), id) { }154void ${domainName}BackendDispatcherHandler::${callbackName}::sendSuccess(${formalParameters})155{156 Ref<JSON::Object> jsonMessage = JSON::Object::create();157${outParameterAssignments}158 CallbackBase::sendSuccess(WTFMove(jsonMessage));159}""")160 FrontendDispatcherDomainDispatcherDeclaration = (161"""${classAndExportMacro} ${domainName}FrontendDispatcher {162 WTF_MAKE_FAST_ALLOCATED;163public:164 ${domainName}FrontendDispatcher(FrontendRouter& frontendRouter) : m_frontendRouter(frontendRouter) { }165${eventDeclarations}166private:167 FrontendRouter& m_frontendRouter;168};""")169 ProtocolObjectBuilderDeclarationPrelude = (170""" template<int STATE>171 class Builder {172 private:173 RefPtr<JSON::Object> m_result;174 template<int STEP> Builder<STATE | STEP>& castState()175 {176 return *reinterpret_cast<Builder<STATE | STEP>*>(this);177 }178 Builder(Ref</*${objectType}*/JSON::Object>&& object)179 : m_result(WTFMove(object))180 {181 COMPILE_ASSERT(STATE == NoFieldsSet, builder_created_in_non_init_state);182 }183 friend class ${objectType};184 public:""")185 ProtocolObjectBuilderDeclarationPostlude = (186"""187 Ref<${objectType}> release()188 {189 COMPILE_ASSERT(STATE == AllFieldsSet, result_is_not_ready);190 COMPILE_ASSERT(sizeof(${objectType}) == sizeof(JSON::Object), cannot_cast);191 Ref<JSON::Object> jsonResult = m_result.releaseNonNull();192 auto result = WTFMove(*reinterpret_cast<Ref<${objectType}>*>(&jsonResult));193 return result;194 }195 };196 /*197 * Synthetic constructor:198${constructorExample}199 */200 static Builder<NoFieldsSet> create()201 {202 return Builder<NoFieldsSet>(JSON::Object::create());203 }""")204 ProtocolObjectRuntimeCast = (205"""RefPtr<${objectType}> BindingTraits<${objectType}>::runtimeCast(RefPtr<JSON::Value>&& value)206{207 RefPtr<JSON::Object> result;208 bool castSucceeded = value->asObject(result);209 ASSERT_UNUSED(castSucceeded, castSucceeded);210 BindingTraits<${objectType}>::assertValueHasExpectedType(result.get());211 COMPILE_ASSERT(sizeof(${objectType}) == sizeof(JSON::ObjectBase), type_cast_problem);212 return static_cast<${objectType}*>(static_cast<JSON::ObjectBase*>(result.get()));213}...

Full Screen

Full Screen

test_dispatcher.py

Source:test_dispatcher.py Github

copy

Full Screen

...35@pytest.fixture()36def setup_aliases(monkeypatch):37 monkeypatch.setattr('slackbot.settings.ALIASES', ','.join(TEST_ALIASES))38@pytest.fixture()39def dispatcher(monkeypatch):40 monkeypatch.setattr('slackbot.settings.DEFAULT_REPLY', 'sorry')41 dispatcher = slackbot.dispatcher.MessageDispatcher(None, None, None)42 monkeypatch.setattr(dispatcher, '_get_bot_id', lambda: FAKE_BOT_ID)43 monkeypatch.setattr(dispatcher, '_get_bot_name', lambda: FAKE_BOT_NAME)44 dispatcher._client = FakeClient()45 dispatcher._plugins = FakePluginManager()46 return dispatcher47def test_aliases(setup_aliases, dispatcher):48 msg = {49 'channel': 'C99999'50 }51 for a in TEST_ALIASES:52 msg['text'] = a + ' hello'53 msg = dispatcher.filter_text(msg)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful