Best Python code snippet using lemoncheesecake
test_fixture.py
Source:test_fixture.py
1# Copyright 2018 Red Hat2#3# Licensed under the Apache License, Version 2.0 (the "License"); you may4# not use this file except in compliance with the License. You may obtain5# a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the12# License for the specific language governing permissions and limitations13# under the License.14from __future__ import absolute_import15import os16import sys17import unittest18import fixtures19import mock20import testtools21from testtools import content22import tobiko23from tobiko.tests import unit24def canonical_name(cls):25 return __name__ + '.' + cls.__name__26class MyBaseFixture(tobiko.SharedFixture):27 def __init__(self):28 super(MyBaseFixture, self).__init__()29 self.setup_fixture = mock.Mock(30 specs=tobiko.SharedFixture.setup_fixture)31 self.cleanup_fixture = mock.Mock(32 specs=tobiko.SharedFixture.cleanup_fixture)33class MySkyppingFixture(tobiko.SharedFixture):34 def setup_fixture(self):35 tobiko.skip_test('some-reason')36 def cleanup_fixture(self):37 tobiko.skip_test('some-reason')38class MyFixture(MyBaseFixture):39 pass40class GetFixtureTest(unit.TobikoUnitTest):41 def test_by_name(self):42 self._test_get_fixture(canonical_name(MyFixture))43 def test_by_type(self):44 self._test_get_fixture(MyFixture)45 def test_by_instance(self):46 self._test_get_fixture(MyFixture())47 def _test_get_fixture(self, obj):48 fixture = tobiko.get_fixture(obj)49 self.assertIsInstance(fixture, MyFixture)50 self.assertIs(fixture, tobiko.get_fixture(obj))51 if isinstance(obj, fixtures.Fixture):52 self.assertIs(obj, fixture)53 else:54 self.assertIs(fixture, tobiko.get_fixture(55 canonical_name(MyFixture)))56 fixture.setup_fixture.assert_not_called()57 fixture.cleanup_fixture.assert_not_called()58 for fixture_id in range(2):59 other = tobiko.get_fixture(obj, fixture_id=fixture_id)60 if isinstance(obj, fixtures.Fixture) or not fixture_id:61 self.assertIs(fixture, other)62 else:63 self.assertIsNot(fixture, other)64class GetFixtureNameTest(unit.TobikoUnitTest):65 def test_with_instance(self):66 fixture = MyFixture()67 result = tobiko.get_fixture_name(fixture)68 self.assertEqual(canonical_name(MyFixture), result)69 def test_with_other_type(self):70 obj = object()71 ex = self.assertRaises(TypeError, tobiko.get_fixture_name, obj)72 self.assertEqual('Object {obj!r} is not a fixture.'.format(obj=obj),73 str(ex))74class GetFixtureClassTest(unit.TobikoUnitTest):75 def test_with_name(self):76 result = tobiko.get_fixture_class(canonical_name(MyFixture))77 self.assertIs(MyFixture, result)78 def test_with_type(self):79 result = tobiko.get_fixture_class(MyFixture)80 self.assertIs(MyFixture, result)81 def test_with_instance(self):82 result = tobiko.get_fixture_class(MyFixture())83 self.assertIs(MyFixture, result)84class GetFixtureDirTest(unit.TobikoUnitTest):85 expected_dir = os.path.dirname(__file__)86 def test_with_name(self):87 actual_dir = tobiko.get_fixture_dir(canonical_name(MyFixture))88 self.assertEqual(self.expected_dir, actual_dir)89 def test_with_type(self):90 actual_dir = tobiko.get_fixture_dir(MyFixture)91 self.assertEqual(self.expected_dir, actual_dir)92 def test_with_instance(self):93 actual_dir = tobiko.get_fixture_dir(MyFixture())94 self.assertEqual(self.expected_dir, actual_dir)95class RemoveFixtureTest(unit.TobikoUnitTest):96 def test_with_name(self):97 self._test_remove_fixture(canonical_name(MyFixture))98 def test_with_type(self):99 self._test_remove_fixture(MyFixture)100 def test_with_name_and_fixture_id(self):101 self._test_remove_fixture(canonical_name(MyFixture), fixture_id=5)102 def test_with_type_and_fixture_id(self):103 self._test_remove_fixture(MyFixture, fixture_id=6)104 def _test_remove_fixture(self, obj, fixture_id=None):105 fixture = tobiko.get_fixture(obj, fixture_id=fixture_id)106 result = tobiko.remove_fixture(obj, fixture_id=fixture_id)107 self.assertIs(fixture, result)108 self.assertIsNot(fixture, tobiko.get_fixture(obj,109 fixture_id=fixture_id))110 fixture.setup_fixture.assert_not_called()111 fixture.cleanup_fixture.assert_not_called()112class SetupFixtureTest(unit.TobikoUnitTest):113 def test_with_name(self):114 self._test_setup_fixture(canonical_name(MyFixture))115 def test_with_type(self):116 self._test_setup_fixture(MyFixture)117 def test_with_instance(self):118 self._test_setup_fixture(MyFixture2())119 def test_with_name_and_fixture_id(self):120 self._test_setup_fixture(canonical_name(MyFixture), fixture_id=5)121 def test_with_type_and_fixture_id(self):122 self._test_setup_fixture(MyFixture, fixture_id=6)123 def test_with_instance_and_fixture_id(self):124 self._test_setup_fixture(MyFixture2(), fixture_id=7)125 def _test_setup_fixture(self, obj, fixture_id=None):126 result = tobiko.setup_fixture(obj, fixture_id=fixture_id)127 self.assertIs(tobiko.get_fixture(obj, fixture_id=fixture_id), result)128 result.setup_fixture.assert_called_once_with()129 result.cleanup_fixture.assert_not_called()130class UseFixtureTest(unit.TobikoUnitTest):131 def test_with_name(self):132 self._test_use_fixture(canonical_name(MyFixture))133 def test_with_type(self):134 self._test_use_fixture(MyFixture)135 def test_with_instance(self):136 self._test_use_fixture(MyFixture2())137 def test_with_name_and_fixture_id(self):138 self._test_use_fixture(canonical_name(MyFixture), fixture_id=5)139 def test_with_type_and_fixture_id(self):140 self._test_use_fixture(MyFixture, fixture_id=6)141 def test_with_instance_and_fixture_id(self):142 self._test_use_fixture(MyFixture2(), fixture_id=7)143 def _test_use_fixture(self, obj, fixture_id=None):144 fixture: MyFixture = tobiko.get_fixture(145 obj=obj, fixture_id=fixture_id) # type: ignore146 class InnerTest(unittest.TestCase):147 def runTest(self):148 fixture.setup_fixture.assert_not_called()149 fixture.cleanup_fixture.assert_not_called()150 result = tobiko.use_fixture(obj, fixture_id=fixture_id)151 fixture.setup_fixture.assert_called_once_with()152 fixture.cleanup_fixture.assert_not_called()153 self.assertIs(fixture, result)154 fixture.setup_fixture.assert_not_called()155 fixture.cleanup_fixture.assert_not_called()156 result = tobiko.run_test(InnerTest())157 fixture.setup_fixture.assert_called_once_with()158 fixture.cleanup_fixture.assert_called_once_with()159 self.assertEqual(1, result.testsRun)160 self.assertEqual([], result.errors)161 self.assertEqual([], result.failures)162class ResetFixtureTest(unit.TobikoUnitTest):163 def test_with_name(self):164 self._test_reset_fixture(canonical_name(MyFixture))165 def test_with_type(self):166 self._test_reset_fixture(MyFixture)167 def test_with_instance(self):168 self._test_reset_fixture(MyFixture2())169 def test_with_name_and_fixture_id(self):170 self._test_reset_fixture(canonical_name(MyFixture), fixture_id=5)171 def test_with_type_and_fixture_id(self):172 self._test_reset_fixture(MyFixture, fixture_id=6)173 def test_with_instance_and_fixture_id(self):174 self._test_reset_fixture(MyFixture(), fixture_id=7)175 def test_after_setup(self):176 fixture = MyFixture2()177 fixture.setUp()178 fixture.setup_fixture.reset_mock()179 self._test_reset_fixture(fixture)180 def test_after_cleanup(self):181 fixture = MyFixture2()182 fixture.cleanUp()183 self._test_reset_fixture(fixture)184 def _test_reset_fixture(self, obj, fixture_id=None, should_clean=True):185 result = tobiko.reset_fixture(obj, fixture_id=fixture_id)186 self.assertIs(tobiko.get_fixture(obj, fixture_id=fixture_id), result)187 result.setup_fixture.assert_called_once_with()188 if should_clean:189 result.cleanup_fixture.assert_called_once_with()190 else:191 result.cleanup_fixture.assert_not_called()192class FailingFixture(tobiko.SharedFixture):193 def setup_fixture(self):194 raise RuntimeError('raised by setup_fixture')195 def cleanup_fixture(self):196 raise RuntimeError('raised by cleanup_fixture')197 def getDetails(self):198 content_object = tobiko.details_content(199 content_type=content.UTF8_TEXT,200 content_id=self.fixture_name,201 get_text=lambda: 'My failure details')202 return {'failing fixture': content_object}203class FailingSetupFixtureWhenFailingTest(unit.TobikoUnitTest):204 def test_with_name(self):205 self._test_setup_fixture(canonical_name(FailingFixture))206 def test_with_type(self):207 self._test_setup_fixture(FailingFixture)208 def test_with_instance(self):209 self._test_setup_fixture(FailingFixture())210 def test_with_name_and_fixture_id(self):211 self._test_setup_fixture(canonical_name(FailingFixture), fixture_id=5)212 def test_with_type_and_fixture_id(self):213 self._test_setup_fixture(FailingFixture, fixture_id=6)214 def test_with_instance_and_fixture_id(self):215 self._test_setup_fixture(FailingFixture(), fixture_id=7)216 def _test_setup_fixture(self, obj, fixture_id=None):217 ex = self.assertRaises(218 RuntimeError, tobiko.setup_fixture, obj, fixture_id=fixture_id)219 self.assertEqual('raised by setup_fixture', str(ex))220class CleanupFixtureTest(unit.TobikoUnitTest):221 def test_with_name(self):222 self._test_cleanup_fixture(canonical_name(MyFixture))223 def test_with_type(self):224 self._test_cleanup_fixture(MyFixture)225 def test_with_instance(self):226 self._test_cleanup_fixture(MyFixture())227 def test_with_name_and_fixture_id(self):228 self._test_cleanup_fixture(canonical_name(MyFixture), fixture_id=5)229 def test_with_type_and_fixture_id(self):230 self._test_cleanup_fixture(MyFixture, fixture_id=6)231 def test_with_instance_and_fixture_id(self):232 self._test_cleanup_fixture(MyFixture(), fixture_id=7)233 def _test_cleanup_fixture(self, obj, fixture_id=None):234 result = tobiko.cleanup_fixture(obj, fixture_id=fixture_id)235 self.assertIs(tobiko.get_fixture(obj, fixture_id=fixture_id), result)236 result.setup_fixture.assert_not_called()237 result.cleanup_fixture.assert_called_once_with()238class MyFixtureWithProperty(MyBaseFixture):239 @tobiko.fixture_property240 def some_property(self):241 return id(self)242class FixturePropertyTest(unit.TobikoUnitTest):243 def test_with_instance(self):244 fixture = tobiko.get_fixture(MyFixtureWithProperty)245 self.assertEqual(id(fixture), fixture.some_property)246 def test_without_instance(self):247 fixture = tobiko.get_fixture(MyFixtureWithProperty)248 self.assertEqual(id(fixture), MyFixtureWithProperty.some_property)249class MyFixture2(MyBaseFixture):250 pass251class MyRequiredFixture(MyBaseFixture):252 pass253class RequiredFixtureTest(unit.TobikoUnitTest):254 required_fixture = tobiko.required_fixture(MyRequiredFixture)255 required_fixture_no_setup = tobiko.required_fixture(256 MyRequiredFixture, setup=False)257 def test_list_required_fixtures_with_module(self):258 module = sys.modules[__name__]259 result = tobiko.list_required_fixtures([module])260 self.assertEqual([], result)261 def test_list_required_fixtures_with_module_name(self):262 result = tobiko.list_required_fixtures([__name__])263 self.assertEqual([], result)264 def test_list_required_fixtures_with_testcase_type(self):265 result = tobiko.list_required_fixtures([RequiredFixtureTest])266 self.assertEqual([canonical_name(MyRequiredFixture)], result)267 def test_list_required_fixtures_with_testcase_name(self):268 result = tobiko.list_required_fixtures(269 [canonical_name(RequiredFixtureTest)])270 self.assertEqual([canonical_name(MyRequiredFixture)], result)271 def test_list_required_fixtures_with_unbound_method(272 self, fixture=MyFixture, fixture2=MyFixture2):273 cls = RequiredFixtureTest274 result = tobiko.list_required_fixtures(275 [cls.test_list_required_fixtures_with_unbound_method])276 self.assertEqual([canonical_name(fixture),277 canonical_name(fixture2),278 canonical_name(MyRequiredFixture)], result)279 def test_list_required_fixtures_with_bound_method(280 self, fixture=MyFixture, fixture2=MyFixture2):281 result = tobiko.list_required_fixtures([282 self.test_list_required_fixtures_with_bound_method])283 self.assertEqual([canonical_name(fixture),284 canonical_name(fixture2),285 canonical_name(MyRequiredFixture)], result)286 def test_list_required_fixtures_with_method_name(287 self, fixture=MyFixture, fixture2=MyFixture2):288 result = tobiko.list_required_fixtures([self.id()])289 self.assertEqual([canonical_name(fixture),290 canonical_name(fixture2),291 canonical_name(MyRequiredFixture)], result)292 def test_list_required_fixtures_with_fixture_name(self):293 result = tobiko.list_required_fixtures([canonical_name(MyFixture)])294 self.assertEqual([canonical_name(MyFixture)], result)295 def test_list_required_fixtures_with_fixture(self):296 result = tobiko.list_required_fixtures([MyFixture()])297 self.assertEqual([canonical_name(MyFixture)], result)298 def test__list_required_fixtures_with_fixture_type(self):299 result = tobiko.list_required_fixtures([MyFixture])300 self.assertEqual([canonical_name(MyFixture)], result)301 def test_required_fixture_with_instance(self):302 fixture = self.required_fixture303 self.assertIsInstance(fixture, MyRequiredFixture)304 fixture.setup_fixture.assert_called()305 fixture.cleanup_fixture.assert_not_called()306 def test_required_fixture_with_no_setup(self):307 fixture = self.required_fixture_no_setup308 self.assertIsInstance(fixture, MyRequiredFixture)309 fixture.setup_fixture.assert_not_called()310 fixture.cleanup_fixture.assert_not_called()311class SharedFixtureTest(unit.TobikoUnitTest):312 def setUp(self):313 super(SharedFixtureTest, self).setUp()314 tobiko.remove_fixture(MyFixture)315 def test_init(self):316 fixture = MyFixture()317 fixture.setup_fixture.assert_not_called()318 fixture.cleanup_fixture.assert_not_called()319 def test_get(self):320 fixture = MyFixture.get()321 self.assertIs(tobiko.get_fixture(MyFixture), fixture)322 def test_use_fixture(self):323 fixture = MyFixture()324 self.addCleanup(fixture.cleanup_fixture.assert_called_once_with)325 self.useFixture(fixture)326 fixture.setup_fixture.assert_called_once_with()327 fixture.cleanup_fixture.assert_not_called()328 self.useFixture(fixture)329 fixture.setup_fixture.assert_called_once_with()330 fixture.cleanup_fixture.assert_not_called()331 def test_add_cleanup(self):332 fixture = MyFixture()333 self.addCleanup(fixture.cleanup_fixture.assert_called_once_with)334 self.addCleanup(fixture.cleanUp)335 self.addCleanup(fixture.cleanUp)336 def test_setup(self):337 fixture = MyFixture()338 fixture.setUp()339 fixture.setup_fixture.assert_called_once_with()340 def test_setup_twice(self):341 fixture = MyFixture()342 fixture.setUp()343 fixture.setUp()344 fixture.setup_fixture.assert_called_once_with()345 def test_setup_when_skipping(self):346 fixture = MySkyppingFixture()347 self.assertRaises(testtools.MultipleExceptions, fixture.setUp)348 self.assertRaises(testtools.MultipleExceptions, fixture.setUp)349 def test_cleanup(self):350 fixture = MyFixture()351 fixture.cleanUp()352 fixture.cleanup_fixture.assert_called_once_with()353 def test_cleanup_twice(self):354 fixture = MyFixture()355 fixture.cleanUp()356 fixture.cleanUp()357 fixture.cleanup_fixture.assert_called_once_with()358 def test_cleanup_when_skipping(self):359 fixture = MySkyppingFixture()360 self.assertRaises(tobiko.SkipException, fixture.cleanUp)361 self.assertRaises(testtools.MultipleExceptions, fixture.cleanUp)362 def test_lifecycle(self):363 fixture = MyFixture()364 for call_count in range(3):365 fixture.setUp()366 fixture.setup_fixture.assert_has_calls([mock.call()] * call_count)367 fixture.setUp()368 fixture.setup_fixture.assert_has_calls([mock.call()] * call_count)369 fixture.cleanUp()370 fixture.cleanup_fixture.assert_has_calls(371 [mock.call()] * call_count)372 fixture.cleanUp()373 fixture.cleanup_fixture.assert_has_calls(374 [mock.call()] * call_count)375 def test_fixture_name(self):376 fixture = tobiko.get_fixture(MyFixture)377 self.assertEqual(f'{__name__}.{MyFixture.__qualname__}',378 fixture.fixture_name)379 def test_fixture_name_with_fixture_id(self):380 fixture = tobiko.get_fixture(MyFixture, fixture_id=10)381 self.assertEqual(f'{__name__}.{MyFixture.__qualname__}-10',382 fixture.fixture_name)383 def test_fixture_id(self):384 fixture = tobiko.get_fixture(MyFixture)385 self.assertIsNone(fixture.fixture_id)386 def test_fixture_id_with_fixture_id(self):387 fixture = tobiko.get_fixture(MyFixture, fixture_id=12)...
CuryCueConnector.py
Source:CuryCueConnector.py
1import mysql.connector2import urllib3import sys4import re5import os6from collections import namedtuple, OrderedDict7from dataclasses import dataclass8from typing import Any9class CuryCueConnector:10 def __init__(self):11 pass12 def checkFixtureByPath(self,path):13 found=False14 if path in self.LocalFixturesByPath.keys():15 found=True16 return found17 def checkFixtureParByName(self,fixture,name):18 found=False19 for par in fixture.pars:20 if par.par_name==name:21 found=True22 return found23 def LoadCue(self):24 self.LocalCueData = []25 self.LocalFixtureData = []26 fields = ['id', 'order', 'name', 'memo', 'type', 'update_mode', 'linked', 27 'osc_bind', 'dmx_bind', 'is_enabled']28 myQuery = self.QUERY(table='cue', fields=fields, 29 condition=" is_enabled='1'", conditionData=[], order=" `order` ")30 for raw_row_cue in self.getListByFields(myQuery):31 self.LocalCueData.append(self.LoadDBtoStruct(32 self.CUE(), myQuery, raw_row_cue))33 def LoadCueFloatData(self):34 35 for cue in self.LocalCueData:36 fields = ['id', 'id_fixture', 'par_name', 'par_value',37 'fade_in', 'fade_out', 'delay_in', 'delay_out', 'par_text_value']38 fields_query_prefix=[]39 for f in fields:40 fields_query_prefix.append('cfd')41 42 43 myQuery = self.QUERY(table='cue_float_data as cfd, fixture as fix', fields=fields, fields_query_prefix = fields_query_prefix,44 condition=" cfd.id_cue=%s and cfd.id_fixture=fix.id", conditionData=[int(cue.id)], order=" fix.`order` ")45 myParsList = list()46 myParsDict = dict()47 48 for raw_row_cue in self.getListByFields(myQuery):49 # print (raw_row_cue)50 myParsFloat = self.LoadDBtoStruct(self.CUEPARFLOAT(), myQuery, raw_row_cue)51 myParsDictByFixId = dict ()52 myFixture=self.LocalFixturesByID[myParsFloat.id_fixture]53 # ÑÑиваем пÑÑÑ Ð´Ð»Ñ ÑникалÑного ID полÑ54 myFixturePath=myFixture.global_object_location55 myParsFloat.full_par_path="{}:{}".format(myFixturePath, myParsFloat.par_name)56 #57 myParsFloat.fixture=myFixture58 # добавлÑем в обÑий ÑпиÑок паÑамеÑÑов клÑÑа 59 myParsList.append(myParsFloat)60 myParsDict[myParsFloat.full_par_path]=myParsFloat61 if myParsFloat.id_fixture not in myParsDictByFixId.keys():62 myParsDictByFixId[myParsFloat.id_fixture]=[]63 myParsDictByFixId[myParsFloat.id_fixture].append(myParsFloat)64 cue.pars_float = myParsList65 cue.pars_float_by_path = myParsDict66 try:67 cue.pars_float_by_fix_id=myParsDictByFixId68 except:69 cue.pars_float_by_fix_id=dict()70 # self.LoadDBtoStruct(myCueFloatPar, myQuery)71 # print (myCueFloatPar)72 pass73 def LoadCueFloatDataV2(self):74 CUE_PROCESS_CURSOR = []75 CUE_PROCESS_CURSORbyPath = dict()76 _allPars=[]77 for myFixture in self.LocalFixtureData:78 for myPars in myFixture.pars:79 myPathFull="{}:{}".format(myFixture.global_object_location, myPars.par_name)80 myField = self.ACTIVE_FIELDS(81 id_par=myPars.id, id_fixture=myFixture.id, fixture_name=myFixture.name, 82 fixture_object_location=myFixture.global_object_location, par_name=myPars.par_name,83 par_value=myPars.default_value,par_text_value='', is_fixture_enabled=myFixture.is_enabled, 84 fixture_ref=myFixture, fixture_par_ref=myPars, full_par_path=myPathFull, fade_in = myPars.fade_default, 85 delay_in = myPars.delay_default)86 # маÑÑив, по коÑоÑÐ¾Ð¼Ñ Ð±Ñдем пÑогонÑÑÑ Ð²Ñе клÑÑи 87 CUE_PROCESS_CURSOR.append(myField)88 CUE_PROCESS_CURSORbyPath[myPathFull]=myField89 # ÑкладÑваем вÑе Ð¿Ð¾Ð»Ñ Ð¿ÑоÑоÑипа в маÑÑив Ð´Ð»Ñ Ð¿Ð¾Ð¸Ñка по ним 90 _allPars.append(myPars)91 92 # паÑамеÑÑÑ ÐºÐ»ÑÑей обогоÑаем ÑÑÑлкой на пÑоÑоÑип ÑикÑÑеÑа93 for myCue in self.LocalCueData:94 for myCuePar in myCue.pars_float:95 if myCuePar.par_name in myCuePar.fixture.pars_float_by_name.keys():96 _fix_par_match=myCuePar.fixture.pars_float_by_name[myCuePar.par_name]97 myCuePar.fixture_par_ref=_fix_par_match98 #99 100 _fields = ['par_name', 'par_value','par_text_value','fade_in', 'delay_in', 'fixture_name', 'id_fixture', 'fixture_object_location', 'full_par_path']101 # ÐÐ ÐÐ¥ÐÐÐÐ ÐÐЮЧÐ, ÐÐÐÐÐÐЯЯ ÐУСТЫРÐÐÐЧÐÐÐЯ ÐÐ ÐÐ ÐÐЫÐУЩÐÐ¥ ÐÐÐ ÐÐФÐÐТÐЫХ 102 for myCue in self.LocalCueData:103 listForChangedFieldsByCue=[]104 for cuePar in myCue.pars_float:105 if cuePar.fixture_par_ref in _allPars:106 for f in _fields:107 v=getattr(cuePar, f)108 setattr(CUE_PROCESS_CURSORbyPath[cuePar.full_par_path], f, v)109 setattr(CUE_PROCESS_CURSORbyPath[cuePar.full_par_path], "id_par_cue", cuePar.id)110 listForChangedFieldsByCue.append(cuePar.fixture_par_ref)111 112 #############################################################################113 # ÐÐТ ТУТ ÐÐÐÐ ÐÐ ÐСÐÐÐТЬ ÐÐЮЧÐРТРЧТРУ ÐÐÐ¥ ÐÐ ÐЫÐÐ114 for fixPar in _allPars:115 if fixPar not in listForChangedFieldsByCue:116 for cpc in CUE_PROCESS_CURSOR:117 if cpc.fixture_par_ref is fixPar:118 119 myFix=self.LocalFixturesByID[cpc.id_fixture]120 myPathFull="{}:{}".format(myFix.global_object_location, cpc.par_name)121 newPar=self.CUEPARFLOAT(id=-1, par_name=cpc.par_name,par_value=cpc.par_value,par_text_value=cpc.par_text_value, fade_in=cpc.fade_in, delay_in=cpc.delay_in,122 id_fixture=cpc.id_fixture, fixture_name=cpc.fixture_name, fixture_object_location=cpc.fixture_name,123 full_par_path=myPathFull, fixture=myFix, is_derived=True)124 myCue.pars_float.append(newPar)125 myCue.pars_float_by_path[myPathFull]=newPar126 127 128 pass129 #############################################################################130 # ÐЫЧÐСÐЯÐÐ ÐÐÐ ÐÐÐТРС СÐÐЫРÐÐÐÐÐЫРФÐÐÐÐÐ Ð ÐÐ ÐÐÐСЫÐÐÐÐ ÐÐÐ Ð parWithLongestFade131 #############################################################################132 # for myCue in self.LocalCueData:133 # parsTime=dict()134 # for cuePar in myCue.pars_float:135 # parsTime[cuePar.fade_in+cuePar.delay_in]=cuePar136 # parsTime=dict(sorted(parsTime.items()))137 # if len(parsTime.keys())>0:138 # longestPar=parsTime.popitem()139 # myCue.parWithLongestFade=longestPar[1].par_name140 # print ("Cue name: {}, par: {}".format(myCue.name, longestPar[1].par_name))141 142 143 144 # parWithLongestFade145 146 147 #CUE_PROCESS_CURSORbyPath148 pass149 def ResortCuesByID(self):150 for cue in self.LocalCueData:151 self.LocalCueDataByID[cue.id]=cue152 def LoadFixtureData(self):153 fields = ['id', 'order', 'name', 'global_object_location', 'type', 'is_enabled']154 self.LocalFixtureData = list()155 self.LocalFixturesByID=dict()156 self.LocalFixturesByPath=dict()157 myQuery = self.QUERY(table='fixture', fields=fields,158 condition="", conditionData=[], order=" `order`")159 for raw_row_cue in self.getListByFields(myQuery):160 myFixture = self.LoadDBtoStruct(161 self.FIXTURE(), myQuery, raw_row_cue)162 myFixture.original_location=myFixture.global_object_location163 if re.search(r'op\..+', myFixture.global_object_location):164 res = re.match(165 r'op\.(.+)', myFixture.global_object_location).groups()[0]166 if hasattr(op, res):167 myFixture.global_object_location = getattr(op, res).path168 # print (getattr(op, str(res)).path)169 # myFixture.global_object_location=op170 #print (myFixture.global_object_location)171 self.LocalFixtureData.append(myFixture)172 self.LocalFixturesByID[myFixture.id]=myFixture173 self.LocalFixturesByPath[myFixture.global_object_location]=myFixture174 pass175 def LoadFixturePars(self):176 for myFixture in self.LocalFixtureData:177 fields = ['id', 'id_fixture', 'par_name',178 'par_name', 'default_value','fade_default', 'delay_default', 'is_enabled']179 myQuery = self.QUERY(table='fixture_float_data', fields=fields,180 condition=" id_fixture=%s", conditionData=[int(myFixture.id)], order="")181 myParsList = list()182 myParsDict = dict()183 for raw_row_cue in self.getListByFields(myQuery):184 myParsFloat = self.LoadDBtoStruct(185 self.FIXPAR(), myQuery, raw_row_cue)186 myParsFloat.name = myFixture.name187 myParsFloat.global_object_location = myFixture.global_object_location188 myParsFloat.id_fixture=myFixture.id189 myParsList.append(myParsFloat)190 myParsDict[myParsFloat.par_name]=myParsFloat191 myFixture.pars = myParsList192 myFixture.pars_float_by_name = myParsDict193 def CreateActiveFields(self):194 self.ActiveFields = list()195 self.ActiveFieldsByPath = dict()196 for myFixture in self.LocalFixtureData:197 for myPars in myFixture.pars:198 myPathFull="{}:{}".format(myFixture.global_object_location, myPars.par_name)199 myField = self.ACTIVE_FIELDS(200 id_par=myPars.id, id_fixture=myFixture.id, fixture_name=myFixture.name, 201 fixture_object_location=myFixture.global_object_location, par_name=myPars.par_name,202 par_value=myPars.default_value, is_fixture_enabled=myFixture.is_enabled, 203 fixture_ref=myFixture, fixture_par_ref=myPars, full_par_path=myPathFull)204 self.ActiveFields.append(myField)205 self.ActiveFieldsByPath[myPathFull]=myField206 def LoadDBtoStruct(self, myStruct, myQuery, raw_row_cue):207 i = 0208 for myValue in raw_row_cue:209 myField = myQuery.fields[i]210 if re.search("\.", myField):211 print ("AA!!")212 #print ("Name: {}, Value: {}".format(myField, myValue))213 setattr(myStruct, myField, myValue)214 i += 1...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!