How to use _get_class method in tempest

Best Python code snippet using tempest_python

utilsfactory.py

Source:utilsfactory.py Github

copy

Full Screen

...91 'ioutils': [92 {'path': 'os_win.utils.io.ioutils.IOUtils'},93 ],94}95def _get_class(class_type, *args, **kwargs):96 if class_type not in utils_map:97 raise exceptions.HyperVException(_('Class type %s does '98 'not exist') % class_type)99 windows_version = utils.get_windows_version()100 build = list(map(int, windows_version.split('.')))101 windows_version = float("%i.%i" % (build[0], build[1]))102 existing_classes = utils_map.get(class_type, [])103 for class_variant in existing_classes:104 min_version = class_variant.get('min_version', DEFAULT_MIN_VERSION)105 max_version = class_variant.get('max_version', DEFAULT_MAX_VERSION)106 class_path = class_variant['path']107 if (min_version <= windows_version and108 (max_version is None or windows_version < max_version)):109 return importutils.import_object(class_path, *args, **kwargs)110 raise exceptions.HyperVException(_('Could not find any %(class)s class for'111 'this Windows version: %(win_version)s')112 % {'class': class_type,113 'win_version': windows_version})114def get_vmutils(host='.'):115 return _get_class(class_type='vmutils', host=host)116def get_vhdutils():117 return _get_class(class_type='vhdutils')118def get_metricsutils():119 return _get_class(class_type='metricsutils')120def get_networkutils():121 return _get_class(class_type='networkutils')122def get_nvgreutils():123 return _get_class(class_type='nvgreutils')124def get_hostutils():125 return _get_class(class_type='hostutils')126def get_pathutils():127 return _get_class(class_type='pathutils')128def get_iscsi_initiator_utils():129 return _get_class(class_type='iscsi_initiator_utils')130def get_livemigrationutils():131 return _get_class(class_type='livemigrationutils')132def get_smbutils():133 return _get_class(class_type='smbutils')134def get_rdpconsoleutils():135 return _get_class(class_type='rdpconsoleutils')136def get_iscsi_target_utils():137 return _get_class(class_type='iscsi_target_utils')138def get_named_pipe_handler(*args, **kwargs):139 return namedpipe.NamedPipeHandler(*args, **kwargs)140def get_fc_utils():141 return _get_class(class_type='fc_utils')142def get_diskutils():143 return _get_class(class_type='diskutils')144def get_clusterutils():145 return _get_class(class_type='clusterutils')146def get_dnsutils():147 return _get_class(class_type='dnsutils')148def get_migrationutils():149 return _get_class(class_type='migrationutils')150def get_processutils():151 return _get_class(class_type='processutils')152def get_ioutils():153 return _get_class(class_type='ioutils')154def get_mutex(*args, **kwargs):...

Full Screen

Full Screen

test_requests_builder.py

Source:test_requests_builder.py Github

copy

Full Screen

1import pytest2from ..custom_errors import WrongAttrError, WrongValueError3from ..requests_builder import IssueSearchRequest, SearchRequest4class TestSearchRequest: # TODO: patch aiohttp and gino5 def _get_class(self, data_type=None, q_params=None, page=1):6 class_dict = {}7 def init(self):8 if q_params is not None:9 self.query_params = q_params10 super(self.__class__, self).__init__(page)11 class_dict["__init__"] = init12 if data_type is not None:13 class_dict["data_type"] = data_type14 return type("ExampleClass", (SearchRequest,), class_dict)15 def test_url(self):16 correct_url = "https://api.github.com/search/right?q=one:a+two:b&page=1"17 child = self._get_class(data_type="right", q_params={"one": "a", "two": "b"})()18 assert child.url == correct_url19 def test_url_with_not_bool_page(self):20 correct_url = "https://api.github.com/search/right?q=one:a+two:b&page=1"21 child = self._get_class(22 data_type="right", q_params={"one": "a", "two": "b"}, page=023 )()24 assert child.url == correct_url25 def test_url_with_no_data_type_attr(self):26 with pytest.raises(WrongAttrError):27 self._get_class(q_params={"one": "a", "two": "b"})()28 def test_url_with_not_bool_data_type_attr(self):29 with pytest.raises(WrongAttrError):30 self._get_class(data_type="", q_params={"one": "a", "two": "b"})()31 def test_url_with_wrong_type_of_data_type_attr(self):32 with pytest.raises(WrongAttrError):33 self._get_class(data_type=1, q_params={"one": "a", "two": "b"})()34 def test_url_with_no_query_params_attr(self):35 with pytest.raises(WrongAttrError):36 self._get_class(data_type="right")()37 def test_url_with_not_bool_query_params_attr(self):38 with pytest.raises(WrongAttrError):39 self._get_class(data_type="right", q_params={})()40 def test_url_with_wrong_type_of_query_params_attr(self):41 with pytest.raises(WrongAttrError):42 self._get_class(data_type="right", q_params=[1, 2, 3])()43 def test_url_with_wrong_type_of_page_attr(self):44 with pytest.raises(WrongAttrError):45 self._get_class(46 data_type="right", q_params={"one": "a", "two": "b"}, page="qwe"47 )()48class TestIssueSearchRequest: # TODO: patch aiohttp and gino49 def test_right_values(self):50 correct_url = (51 "https://api.github.com/search/issues"52 '?q=label:"good first issue"+language:python'53 "+state:open+archived:false&page=3"54 )55 instance = IssueSearchRequest(56 label="good first issue", language="python", page=3,57 )58 assert instance.url == correct_url59 def test_initialize_with_wrong_type_of_label_value(self):...

Full Screen

Full Screen

test_funnel.py

Source:test_funnel.py Github

copy

Full Screen

2import pytest3import unittest24@pytest.mark.funnel5class FunnelTests(unittest2.TestCase):6 def _get_class(self):7 from kardboard.services.funnel import Funnel8 return Funnel9 def test_funnel_state(self):10 config = {11 'Build to OTIS': {12 }13 }14 f = self._get_class()('Build to OTIS', config['Build to OTIS'])15 assert f.state == "Build to OTIS"16 def test_funnel_throughput(self):17 config = {18 'Build to OTIS': {19 'throughput': 2,20 }21 }22 f = self._get_class()('Build to OTIS', config['Build to OTIS'])23 assert 2 == f.throughput24 def test_funnel_no_throughput(self):25 config = {26 'Build to OTIS': {27 }28 }29 f = self._get_class()('Build to OTIS', config['Build to OTIS'])30 assert f.throughput is None31 def test_funnel_auth_none(self):32 config = {33 'Build to OTIS': {34 }35 }36 f = self._get_class()('Build to OTIS', config['Build to OTIS'])37 assert f.is_authorized('joe') is True38 def test_funnel_auth_tru(self):39 config = {40 'Build to OTIS': {41 'auth': ['joe', 'jane']42 }43 }44 f = self._get_class()('Build to OTIS', config['Build to OTIS'])45 assert f.is_authorized('joe') is True46 def test_funnel_auth_false(self):47 config = {48 'Build to OTIS': {49 'auth': ['joe', 'jane']50 }51 }52 f = self._get_class()('Build to OTIS', config['Build to OTIS'])53 assert f.is_authorized('jack') is False54 def test_find_cards(self):55 with mock.patch('kardboard.services.funnel.Kard') as mock_Kard:56 f = self._get_class()('Build to OTIS', {})57 mock_Kard.objects.filter.return_value.exclude.return_value = []58 result = f.find_cards()59 mock_Kard.objects.filter.assert_called_with(60 state="Build to OTIS",61 )62 mock_Kard.objects.filter.return_value.exclude.assert_called_with(63 '_ticket_system_data',64 )65 assert result == []66 def test_state_duration(self):67 with mock.patch('kardboard.services.funnel.StateLog') as mock_StateLog:68 f = self._get_class()('Build to OTIS', {})69 card = mock.Mock()70 fake_statelog = mock.Mock()71 fake_statelog.duration = 2072 mock_StateLog.objects.filter.return_value.order_by.return_value = [fake_statelog, ]73 duration = f.state_duration(card)74 mock_StateLog.objects.filter.assert_called_with(75 card=card,76 state=f.state77 )78 mock_StateLog.objects.filter.return_value.order_by.assert_called_with(79 '-entered',80 )...

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