How to use get_service_clients method in tempest

Best Python code snippet using tempest_python

test_integ_PublishCommand.py

Source:test_integ_PublishCommand.py Github

copy

Full Screen

...16 return_value=mock_get_proj_config.return_value["parsed_component_recipe"],17 )18 return mock_get_proj_config19@pytest.fixture()20def get_service_clients(mocker):21 region = project_config()["region"]22 service_clients = {}23 service_clients["sts_client"] = boto3.client("sts", region_name=region)24 service_clients["s3_client"] = boto3.client("s3", region_name=region)25 service_clients["greengrass_client"] = boto3.client("greengrassv2", region_name=region)26 mocker.patch("gdk.commands.component.project_utils.get_service_clients", return_value=service_clients)27 mocker.patch.object(service_clients["sts_client"], "get_caller_identity", return_value={"Account": 1234})28 mocker.patch.object(service_clients["s3_client"], "create_bucket", return_value=None)29 mocker.patch.object(service_clients["s3_client"], "upload_file", return_value=None)30 mocker.patch.object(service_clients["greengrass_client"], "create_component_version", return_value=None)31 mocker.patch.object(32 service_clients["greengrass_client"],33 "list_component_versions",34 return_value={"componentVersions": [{"componentVersion": "1.0.4"}, {"componentVersion": "1.0.1"}]},...

Full Screen

Full Screen

plugins.py

Source:plugins.py Github

copy

Full Screen

...91 (my_service_features_group.name, MyServiceFeaturesGroup)92 ]93 """94 return []95 def get_service_clients(self):96 """Get a list of the service clients for registration97 If the plugin implements service clients for one or more APIs, it98 may return their details by this method for automatic registration99 in any ServiceClients object instantiated by tests.100 The default implementation returns an empty list.101 :returns: Each element of the list represents the service client for an102 API. Each dict must define all parameters required for the invocation103 of `service_clients.ServiceClients.register_service_client_module`.104 :rtype: list of dictionaries105 Example implementation with one service client::106 def get_service_clients(self):107 # Example implementation with one service client108 myservice_config = config.service_client_config('myservice')109 params = {110 'name': 'myservice',111 'service_version': 'myservice',112 'module_path': 'myservice_tempest_tests.services',113 'client_names': ['API1Client', 'API2Client'],114 }115 params.update(myservice_config)116 return [params]117 Example implementation with two service clients::118 def get_service_clients(self):119 # Example implementation with two service clients120 foo1_config = config.service_client_config('foo')121 params_foo1 = {122 'name': 'foo_v1',123 'service_version': 'foo.v1',124 'module_path': 'bar_tempest_tests.services.foo.v1',125 'client_names': ['API1Client', 'API2Client'],126 }127 params_foo1.update(foo_config)128 foo2_config = config.service_client_config('foo')129 params_foo2 = {130 'name': 'foo_v2',131 'service_version': 'foo.v2',132 'module_path': 'bar_tempest_tests.services.foo.v2',133 'client_names': ['API1Client', 'API2Client'],134 }135 params_foo2.update(foo2_config)136 return [params_foo1, params_foo2]137 """138 return []139@misc.singleton140class TempestTestPluginManager(object):141 """Tempest test plugin manager class142 This class is used to manage the lifecycle of external tempest test143 plugins. It provides functions for getting set144 """145 def __init__(self):146 self.ext_plugins = stevedore.ExtensionManager(147 'tempest.test_plugins', invoke_on_load=True,148 propagate_map_exceptions=True,149 on_load_failure_callback=self.failure_hook)150 @staticmethod151 def failure_hook(_, ep, err):152 LOG.error('Could not load %r: %s', ep.name, err)153 raise err154 def get_plugin_load_tests_tuple(self):155 load_tests_dict = {}156 for plug in self.ext_plugins:157 load_tests_dict[plug.name] = plug.obj.load_tests()158 return load_tests_dict159 def register_plugin_opts(self, conf):160 for plug in self.ext_plugins:161 try:162 plug.obj.register_opts(conf)163 except Exception:164 LOG.exception('Plugin %s raised an exception trying to run '165 'register_opts', plug.name)166 def get_plugin_options_list(self):167 plugin_options = []168 for plug in self.ext_plugins:169 opt_list = plug.obj.get_opt_lists()170 if opt_list:171 plugin_options.extend(opt_list)172 return plugin_options173 def _register_service_clients(self):174 registry = clients.ClientsRegistry()175 for plug in self.ext_plugins:176 try:177 service_clients = plug.obj.get_service_clients()178 if service_clients:179 registry.register_service_client(180 plug.name, service_clients)181 except Exception:182 LOG.exception('Plugin %s raised an exception trying to run '...

Full Screen

Full Screen

test_tempest_plugin.py

Source:test_tempest_plugin.py Github

copy

Full Screen

...43 fake_obj = fake_plugin.FakeStevedoreObj()44 manager.ext_plugins = [fake_obj]45 manager._register_service_clients()46 expected_result = fake_plugin.FakePlugin.expected_service_clients47 registered_clients = registry.get_service_clients()48 self.assertIn(fake_obj.name, registered_clients)49 self.assertEqual(expected_result, registered_clients[fake_obj.name])50 def test__get_service_clients_with_two_plugins(self):51 registry = clients.ClientsRegistry()52 manager = plugins.TempestTestPluginManager()53 obj1 = fake_plugin.FakeStevedoreObj('fake01')54 obj2 = fake_plugin.FakeStevedoreObj('fake02')55 manager.ext_plugins = [obj1, obj2]56 manager._register_service_clients()57 expected_result = fake_plugin.FakePlugin.expected_service_clients58 registered_clients = registry.get_service_clients()59 self.assertIn('fake01', registered_clients)60 self.assertIn('fake02', registered_clients)61 self.assertEqual(expected_result, registered_clients['fake01'])62 self.assertEqual(expected_result, registered_clients['fake02'])63 def test__register_service_clients_one_plugin_no_service_clients(self):64 registry = clients.ClientsRegistry()65 manager = plugins.TempestTestPluginManager()66 fake_obj = fake_plugin.FakeStevedoreObjNoServiceClients()67 manager.ext_plugins = [fake_obj]68 manager._register_service_clients()69 registered_clients = registry.get_service_clients()...

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 tempest 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