Best Python code snippet using localstack_python
Dot3ahEventNotificationConfig_Autogen.py
Source:Dot3ahEventNotificationConfig_Autogen.py
1"""2Auto-generated File 3Create Time: 2019-12-27 02:33:274"""5from .ROMEnum_Autogen import *6from renix_py_api.renix_common_api import *7from renix_py_api import rom_manager8from .ROMObject_Autogen import ROMObject9@rom_manager.rom10class Dot3ahEventNotificationConfig(ROMObject):11 def __init__(self, InitialTime=None, EventRepeatPeriod=None, EnableErroredFrameEvent=None, EfeWindow=None, EfeThreshold=None, EfeErrorCount=None, EnableErroredFramePeriodEvent=None, EfpeWindow=None, EfpeThreshold=None, EfpeErrorCount=None, EnableErroredSymbolPeriodEvent=None, EspeWindow=None, EspeThreshold=None, EspeErrorCount=None, EnableErroredFrameSecondsSummaryEvent=None, EfsseWindow=None, EfsseThreshold=None, EfsseCount=None, EnableOrgSpecEvent=None, OrgSpecEventOUI=None, OrgSpecEventData=None, **kwargs):12 self._InitialTime = InitialTime # Initial Time (100ms)13 self._EventRepeatPeriod = EventRepeatPeriod # Event Repeat Period (sec)14 self._EnableErroredFrameEvent = EnableErroredFrameEvent # Enable Errored Frame Event15 self._EfeWindow = EfeWindow # EFE Window (100ms)16 self._EfeThreshold = EfeThreshold # EFE Threshold (frame)17 self._EfeErrorCount = EfeErrorCount # EFE Error Count18 self._EnableErroredFramePeriodEvent = EnableErroredFramePeriodEvent # Enable Errored Frame Period Event19 self._EfpeWindow = EfpeWindow # EFPE Window (frame)20 self._EfpeThreshold = EfpeThreshold # EFPE Threshold (frame)21 self._EfpeErrorCount = EfpeErrorCount # EFPE Error Count22 self._EnableErroredSymbolPeriodEvent = EnableErroredSymbolPeriodEvent # Enable Errored Symbol Period Event23 self._EspeWindow = EspeWindow # ESPE Window (symbol)24 self._EspeThreshold = EspeThreshold # ESPE Threshold (symbol)25 self._EspeErrorCount = EspeErrorCount # ESPE Error Count26 self._EnableErroredFrameSecondsSummaryEvent = EnableErroredFrameSecondsSummaryEvent # Enable Errored Frame Seconds Summary Event27 self._EfsseWindow = EfsseWindow # EFSSE Window (100ms)28 self._EfsseThreshold = EfsseThreshold # EFSSE Threshold (frames/sec)29 self._EfsseCount = EfsseCount # EFSSE Error Count30 self._EnableOrgSpecEvent = EnableOrgSpecEvent # Enable Organization Specific Event31 self._OrgSpecEventOUI = OrgSpecEventOUI # Organization Specific Event OUI32 self._OrgSpecEventData = OrgSpecEventData # Organization Specific Event Data33 properties = kwargs.copy()34 if InitialTime is not None:35 properties['InitialTime'] = InitialTime36 if EventRepeatPeriod is not None:37 properties['EventRepeatPeriod'] = EventRepeatPeriod38 if EnableErroredFrameEvent is not None:39 properties['EnableErroredFrameEvent'] = EnableErroredFrameEvent40 if EfeWindow is not None:41 properties['EfeWindow'] = EfeWindow42 if EfeThreshold is not None:43 properties['EfeThreshold'] = EfeThreshold44 if EfeErrorCount is not None:45 properties['EfeErrorCount'] = EfeErrorCount46 if EnableErroredFramePeriodEvent is not None:47 properties['EnableErroredFramePeriodEvent'] = EnableErroredFramePeriodEvent48 if EfpeWindow is not None:49 properties['EfpeWindow'] = EfpeWindow50 if EfpeThreshold is not None:51 properties['EfpeThreshold'] = EfpeThreshold52 if EfpeErrorCount is not None:53 properties['EfpeErrorCount'] = EfpeErrorCount54 if EnableErroredSymbolPeriodEvent is not None:55 properties['EnableErroredSymbolPeriodEvent'] = EnableErroredSymbolPeriodEvent56 if EspeWindow is not None:57 properties['EspeWindow'] = EspeWindow58 if EspeThreshold is not None:59 properties['EspeThreshold'] = EspeThreshold60 if EspeErrorCount is not None:61 properties['EspeErrorCount'] = EspeErrorCount62 if EnableErroredFrameSecondsSummaryEvent is not None:63 properties['EnableErroredFrameSecondsSummaryEvent'] = EnableErroredFrameSecondsSummaryEvent64 if EfsseWindow is not None:65 properties['EfsseWindow'] = EfsseWindow66 if EfsseThreshold is not None:67 properties['EfsseThreshold'] = EfsseThreshold68 if EfsseCount is not None:69 properties['EfsseCount'] = EfsseCount70 if EnableOrgSpecEvent is not None:71 properties['EnableOrgSpecEvent'] = EnableOrgSpecEvent72 if OrgSpecEventOUI is not None:73 properties['OrgSpecEventOUI'] = OrgSpecEventOUI74 if OrgSpecEventData is not None:75 properties['OrgSpecEventData'] = OrgSpecEventData76 # call base class function, and it will send message to renix server to create a class.77 super(Dot3ahEventNotificationConfig, self).__init__(**properties)78 def delete(self):79 """80 call to delete itself81 """82 return self._finalize()83 def edit(self, InitialTime=None, EventRepeatPeriod=None, EnableErroredFrameEvent=None, EfeWindow=None, EfeThreshold=None, EfeErrorCount=None, EnableErroredFramePeriodEvent=None, EfpeWindow=None, EfpeThreshold=None, EfpeErrorCount=None, EnableErroredSymbolPeriodEvent=None, EspeWindow=None, EspeThreshold=None, EspeErrorCount=None, EnableErroredFrameSecondsSummaryEvent=None, EfsseWindow=None, EfsseThreshold=None, EfsseCount=None, EnableOrgSpecEvent=None, OrgSpecEventOUI=None, OrgSpecEventData=None, **kwargs):84 properties = kwargs.copy()85 if InitialTime is not None:86 self._InitialTime = InitialTime87 properties['InitialTime'] = InitialTime88 if EventRepeatPeriod is not None:89 self._EventRepeatPeriod = EventRepeatPeriod90 properties['EventRepeatPeriod'] = EventRepeatPeriod91 if EnableErroredFrameEvent is not None:92 self._EnableErroredFrameEvent = EnableErroredFrameEvent93 properties['EnableErroredFrameEvent'] = EnableErroredFrameEvent94 if EfeWindow is not None:95 self._EfeWindow = EfeWindow96 properties['EfeWindow'] = EfeWindow97 if EfeThreshold is not None:98 self._EfeThreshold = EfeThreshold99 properties['EfeThreshold'] = EfeThreshold100 if EfeErrorCount is not None:101 self._EfeErrorCount = EfeErrorCount102 properties['EfeErrorCount'] = EfeErrorCount103 if EnableErroredFramePeriodEvent is not None:104 self._EnableErroredFramePeriodEvent = EnableErroredFramePeriodEvent105 properties['EnableErroredFramePeriodEvent'] = EnableErroredFramePeriodEvent106 if EfpeWindow is not None:107 self._EfpeWindow = EfpeWindow108 properties['EfpeWindow'] = EfpeWindow109 if EfpeThreshold is not None:110 self._EfpeThreshold = EfpeThreshold111 properties['EfpeThreshold'] = EfpeThreshold112 if EfpeErrorCount is not None:113 self._EfpeErrorCount = EfpeErrorCount114 properties['EfpeErrorCount'] = EfpeErrorCount115 if EnableErroredSymbolPeriodEvent is not None:116 self._EnableErroredSymbolPeriodEvent = EnableErroredSymbolPeriodEvent117 properties['EnableErroredSymbolPeriodEvent'] = EnableErroredSymbolPeriodEvent118 if EspeWindow is not None:119 self._EspeWindow = EspeWindow120 properties['EspeWindow'] = EspeWindow121 if EspeThreshold is not None:122 self._EspeThreshold = EspeThreshold123 properties['EspeThreshold'] = EspeThreshold124 if EspeErrorCount is not None:125 self._EspeErrorCount = EspeErrorCount126 properties['EspeErrorCount'] = EspeErrorCount127 if EnableErroredFrameSecondsSummaryEvent is not None:128 self._EnableErroredFrameSecondsSummaryEvent = EnableErroredFrameSecondsSummaryEvent129 properties['EnableErroredFrameSecondsSummaryEvent'] = EnableErroredFrameSecondsSummaryEvent130 if EfsseWindow is not None:131 self._EfsseWindow = EfsseWindow132 properties['EfsseWindow'] = EfsseWindow133 if EfsseThreshold is not None:134 self._EfsseThreshold = EfsseThreshold135 properties['EfsseThreshold'] = EfsseThreshold136 if EfsseCount is not None:137 self._EfsseCount = EfsseCount138 properties['EfsseCount'] = EfsseCount139 if EnableOrgSpecEvent is not None:140 self._EnableOrgSpecEvent = EnableOrgSpecEvent141 properties['EnableOrgSpecEvent'] = EnableOrgSpecEvent142 if OrgSpecEventOUI is not None:143 self._OrgSpecEventOUI = OrgSpecEventOUI144 properties['OrgSpecEventOUI'] = OrgSpecEventOUI145 if OrgSpecEventData is not None:146 self._OrgSpecEventData = OrgSpecEventData147 properties['OrgSpecEventData'] = OrgSpecEventData148 super(Dot3ahEventNotificationConfig, self).edit(**properties)149 @property150 def InitialTime(self):151 """152 get the value of property _InitialTime153 """154 if self.force_auto_sync:155 self.get('InitialTime')156 return self._InitialTime157 @property158 def EventRepeatPeriod(self):159 """160 get the value of property _EventRepeatPeriod161 """162 if self.force_auto_sync:163 self.get('EventRepeatPeriod')164 return self._EventRepeatPeriod165 @property166 def EnableErroredFrameEvent(self):167 """168 get the value of property _EnableErroredFrameEvent169 """170 if self.force_auto_sync:171 self.get('EnableErroredFrameEvent')172 return self._EnableErroredFrameEvent173 @property174 def EfeWindow(self):175 """176 get the value of property _EfeWindow177 """178 if self.force_auto_sync:179 self.get('EfeWindow')180 return self._EfeWindow181 @property182 def EfeThreshold(self):183 """184 get the value of property _EfeThreshold185 """186 if self.force_auto_sync:187 self.get('EfeThreshold')188 return self._EfeThreshold189 @property190 def EfeErrorCount(self):191 """192 get the value of property _EfeErrorCount193 """194 if self.force_auto_sync:195 self.get('EfeErrorCount')196 return self._EfeErrorCount197 @property198 def EnableErroredFramePeriodEvent(self):199 """200 get the value of property _EnableErroredFramePeriodEvent201 """202 if self.force_auto_sync:203 self.get('EnableErroredFramePeriodEvent')204 return self._EnableErroredFramePeriodEvent205 @property206 def EfpeWindow(self):207 """208 get the value of property _EfpeWindow209 """210 if self.force_auto_sync:211 self.get('EfpeWindow')212 return self._EfpeWindow213 @property214 def EfpeThreshold(self):215 """216 get the value of property _EfpeThreshold217 """218 if self.force_auto_sync:219 self.get('EfpeThreshold')220 return self._EfpeThreshold221 @property222 def EfpeErrorCount(self):223 """224 get the value of property _EfpeErrorCount225 """226 if self.force_auto_sync:227 self.get('EfpeErrorCount')228 return self._EfpeErrorCount229 @property230 def EnableErroredSymbolPeriodEvent(self):231 """232 get the value of property _EnableErroredSymbolPeriodEvent233 """234 if self.force_auto_sync:235 self.get('EnableErroredSymbolPeriodEvent')236 return self._EnableErroredSymbolPeriodEvent237 @property238 def EspeWindow(self):239 """240 get the value of property _EspeWindow241 """242 if self.force_auto_sync:243 self.get('EspeWindow')244 return self._EspeWindow245 @property246 def EspeThreshold(self):247 """248 get the value of property _EspeThreshold249 """250 if self.force_auto_sync:251 self.get('EspeThreshold')252 return self._EspeThreshold253 @property254 def EspeErrorCount(self):255 """256 get the value of property _EspeErrorCount257 """258 if self.force_auto_sync:259 self.get('EspeErrorCount')260 return self._EspeErrorCount261 @property262 def EnableErroredFrameSecondsSummaryEvent(self):263 """264 get the value of property _EnableErroredFrameSecondsSummaryEvent265 """266 if self.force_auto_sync:267 self.get('EnableErroredFrameSecondsSummaryEvent')268 return self._EnableErroredFrameSecondsSummaryEvent269 @property270 def EfsseWindow(self):271 """272 get the value of property _EfsseWindow273 """274 if self.force_auto_sync:275 self.get('EfsseWindow')276 return self._EfsseWindow277 @property278 def EfsseThreshold(self):279 """280 get the value of property _EfsseThreshold281 """282 if self.force_auto_sync:283 self.get('EfsseThreshold')284 return self._EfsseThreshold285 @property286 def EfsseCount(self):287 """288 get the value of property _EfsseCount289 """290 if self.force_auto_sync:291 self.get('EfsseCount')292 return self._EfsseCount293 @property294 def EnableOrgSpecEvent(self):295 """296 get the value of property _EnableOrgSpecEvent297 """298 if self.force_auto_sync:299 self.get('EnableOrgSpecEvent')300 return self._EnableOrgSpecEvent301 @property302 def OrgSpecEventOUI(self):303 """304 get the value of property _OrgSpecEventOUI305 """306 if self.force_auto_sync:307 self.get('OrgSpecEventOUI')308 return self._OrgSpecEventOUI309 @property310 def OrgSpecEventData(self):311 """312 get the value of property _OrgSpecEventData313 """314 if self.force_auto_sync:315 self.get('OrgSpecEventData')316 return self._OrgSpecEventData317 @InitialTime.setter318 def InitialTime(self, value):319 self._InitialTime = value320 self.edit(InitialTime=value)321 @EventRepeatPeriod.setter322 def EventRepeatPeriod(self, value):323 self._EventRepeatPeriod = value324 self.edit(EventRepeatPeriod=value)325 @EnableErroredFrameEvent.setter326 def EnableErroredFrameEvent(self, value):327 self._EnableErroredFrameEvent = value328 self.edit(EnableErroredFrameEvent=value)329 @EfeWindow.setter330 def EfeWindow(self, value):331 self._EfeWindow = value332 self.edit(EfeWindow=value)333 @EfeThreshold.setter334 def EfeThreshold(self, value):335 self._EfeThreshold = value336 self.edit(EfeThreshold=value)337 @EfeErrorCount.setter338 def EfeErrorCount(self, value):339 self._EfeErrorCount = value340 self.edit(EfeErrorCount=value)341 @EnableErroredFramePeriodEvent.setter342 def EnableErroredFramePeriodEvent(self, value):343 self._EnableErroredFramePeriodEvent = value344 self.edit(EnableErroredFramePeriodEvent=value)345 @EfpeWindow.setter346 def EfpeWindow(self, value):347 self._EfpeWindow = value348 self.edit(EfpeWindow=value)349 @EfpeThreshold.setter350 def EfpeThreshold(self, value):351 self._EfpeThreshold = value352 self.edit(EfpeThreshold=value)353 @EfpeErrorCount.setter354 def EfpeErrorCount(self, value):355 self._EfpeErrorCount = value356 self.edit(EfpeErrorCount=value)357 @EnableErroredSymbolPeriodEvent.setter358 def EnableErroredSymbolPeriodEvent(self, value):359 self._EnableErroredSymbolPeriodEvent = value360 self.edit(EnableErroredSymbolPeriodEvent=value)361 @EspeWindow.setter362 def EspeWindow(self, value):363 self._EspeWindow = value364 self.edit(EspeWindow=value)365 @EspeThreshold.setter366 def EspeThreshold(self, value):367 self._EspeThreshold = value368 self.edit(EspeThreshold=value)369 @EspeErrorCount.setter370 def EspeErrorCount(self, value):371 self._EspeErrorCount = value372 self.edit(EspeErrorCount=value)373 @EnableErroredFrameSecondsSummaryEvent.setter374 def EnableErroredFrameSecondsSummaryEvent(self, value):375 self._EnableErroredFrameSecondsSummaryEvent = value376 self.edit(EnableErroredFrameSecondsSummaryEvent=value)377 @EfsseWindow.setter378 def EfsseWindow(self, value):379 self._EfsseWindow = value380 self.edit(EfsseWindow=value)381 @EfsseThreshold.setter382 def EfsseThreshold(self, value):383 self._EfsseThreshold = value384 self.edit(EfsseThreshold=value)385 @EfsseCount.setter386 def EfsseCount(self, value):387 self._EfsseCount = value388 self.edit(EfsseCount=value)389 @EnableOrgSpecEvent.setter390 def EnableOrgSpecEvent(self, value):391 self._EnableOrgSpecEvent = value392 self.edit(EnableOrgSpecEvent=value)393 @OrgSpecEventOUI.setter394 def OrgSpecEventOUI(self, value):395 self._OrgSpecEventOUI = value396 self.edit(OrgSpecEventOUI=value)397 @OrgSpecEventData.setter398 def OrgSpecEventData(self, value):399 self._OrgSpecEventData = value400 self.edit(OrgSpecEventData=value)401 def _set_initialtime_with_str(self, value):402 try:403 self._InitialTime = int(value)404 except ValueError:405 self._InitialTime = hex(int(value, 16))406 def _set_eventrepeatperiod_with_str(self, value):407 try:408 self._EventRepeatPeriod = int(value)409 except ValueError:410 self._EventRepeatPeriod = hex(int(value, 16))411 def _set_enableerroredframeevent_with_str(self, value):412 self._EnableErroredFrameEvent = (value == 'True')413 def _set_efewindow_with_str(self, value):414 try:415 self._EfeWindow = int(value)416 except ValueError:417 self._EfeWindow = hex(int(value, 16))418 def _set_efethreshold_with_str(self, value):419 try:420 self._EfeThreshold = int(value)421 except ValueError:422 self._EfeThreshold = hex(int(value, 16))423 def _set_efeerrorcount_with_str(self, value):424 try:425 self._EfeErrorCount = int(value)426 except ValueError:427 self._EfeErrorCount = hex(int(value, 16))428 def _set_enableerroredframeperiodevent_with_str(self, value):429 self._EnableErroredFramePeriodEvent = (value == 'True')430 def _set_efpewindow_with_str(self, value):431 try:432 self._EfpeWindow = int(value)433 except ValueError:434 self._EfpeWindow = hex(int(value, 16))435 def _set_efpethreshold_with_str(self, value):436 try:437 self._EfpeThreshold = int(value)438 except ValueError:439 self._EfpeThreshold = hex(int(value, 16))440 def _set_efpeerrorcount_with_str(self, value):441 try:442 self._EfpeErrorCount = int(value)443 except ValueError:444 self._EfpeErrorCount = hex(int(value, 16))445 def _set_enableerroredsymbolperiodevent_with_str(self, value):446 self._EnableErroredSymbolPeriodEvent = (value == 'True')447 def _set_espewindow_with_str(self, value):448 try:449 self._EspeWindow = int(value)450 except ValueError:451 self._EspeWindow = hex(int(value, 16))452 def _set_espethreshold_with_str(self, value):453 try:454 self._EspeThreshold = int(value)455 except ValueError:456 self._EspeThreshold = hex(int(value, 16))457 def _set_espeerrorcount_with_str(self, value):458 try:459 self._EspeErrorCount = int(value)460 except ValueError:461 self._EspeErrorCount = hex(int(value, 16))462 def _set_enableerroredframesecondssummaryevent_with_str(self, value):463 self._EnableErroredFrameSecondsSummaryEvent = (value == 'True')464 def _set_efssewindow_with_str(self, value):465 try:466 self._EfsseWindow = int(value)467 except ValueError:468 self._EfsseWindow = hex(int(value, 16))469 def _set_efssethreshold_with_str(self, value):470 try:471 self._EfsseThreshold = int(value)472 except ValueError:473 self._EfsseThreshold = hex(int(value, 16))474 def _set_efssecount_with_str(self, value):475 try:476 self._EfsseCount = int(value)477 except ValueError:478 self._EfsseCount = hex(int(value, 16))479 def _set_enableorgspecevent_with_str(self, value):480 self._EnableOrgSpecEvent = (value == 'True')481 def _set_orgspeceventoui_with_str(self, value):482 tmp_value = value.strip()483 if tmp_value.startswith('{'):484 tmp_value = tmp_value[1:-1]485 self._OrgSpecEventOUI = []486 values = tmp_value.split()487 for str_value in values:488 try:489 self._OrgSpecEventOUI.append(int(str_value))490 except ValueError:491 self._OrgSpecEventOUI.append(hex(int(str_value, 16)))492 def _set_orgspeceventdata_with_str(self, value):493 tmp_value = value.strip()494 if tmp_value.startswith('{'):495 tmp_value = tmp_value[1:-1]496 self._OrgSpecEventData = []497 values = tmp_value.split()498 for str_value in values:499 try:500 self._OrgSpecEventData.append(int(str_value))501 except ValueError:...
views.py
Source:views.py
1from django.conf import settings2from django.db import transaction3from django.http import HttpResponse4from django.views.generic import View5import functools6import json7import inspect8import importlib9import time10from . import SmokeTest, ApplicationTestResultSet11def test_class(cls):12 o = cls()13 return o.run()14def run_single_class_test(name, obj):15 if not issubclass(obj, SmokeTest):16 return (0, 0, 0, 0, 0, [], [])17 if name == "SmokeTest":18 # skip the parent class, which is usually imported19 return (0, 0, 0, 0, 0, [], [])20 (run, passed, failed, errored, f_tests, e_tests) = test_class(obj)21 return (1, run, passed, failed, errored, f_tests, e_tests)22def test_application(app):23 """ should return an ApplicationTestResultSet """24 num_test_classes = 025 num_tests_run = 026 num_tests_passed = 027 num_tests_failed = 028 num_tests_errored = 029 failed_tests = []30 errored_tests = []31 a = None32 try:33 a = importlib.import_module("%s.smoke" % app)34 except ImportError:35 # no 'smokes' module for the app36 pass37 except Exception as e:38 num_tests_errored += 139 errored_tests.append(40 'Exception while importing smoke test script: %s' % e)41 if a is not None:42 e_tests = []43 try:44 for name, obj in inspect.getmembers(a, inspect.isclass):45 (classes, run, passed, failed, errored,46 f_tests, e_tests) = run_single_class_test(name, obj)47 num_test_classes += classes48 num_tests_run += run49 num_tests_passed += passed50 num_tests_failed += failed51 num_tests_errored += errored52 failed_tests = failed_tests + f_tests53 errored_tests = errored_tests + e_tests54 except Exception as e:55 # probably an error in setUp() or tearDown()56 num_tests_errored += 157 e_tests.append('Exception during test: %s' % e)58 finally:59 errored_tests = errored_tests + e_tests60 return ApplicationTestResultSet(61 num_test_classes, num_tests_run,62 num_tests_passed, num_tests_errored,63 num_tests_failed, failed_tests,64 errored_tests)65def make_failed_report(result_sets):66 return "\n\n".join(67 [f for f in functools.reduce(68 lambda x, y: x + y, [r.failed for r in result_sets])])69def make_errored_report(result_sets):70 return "\n\n".join(71 [f for f in functools.reduce(72 lambda x, y: x + y, [r.errored for r in result_sets])])73def plaintext_output(status, num_test_classes, num_tests_run,74 num_tests_passed, num_tests_failed,75 num_tests_errored, finish, start, failed_report,76 errored_report):77 return """%s78test classes: %d79tests run: %d80tests passed: %d81tests failed: %d82tests errored: %d83time: %fms84%s85%s""" % (status, num_test_classes, num_tests_run, num_tests_passed,86 num_tests_failed, num_tests_errored, (finish - start) * 1000,87 failed_report, errored_report)88def skip_apps():89 if hasattr(settings, 'SMOKETEST_SKIP_APPS'):90 return settings.SMOKETEST_SKIP_APPS91 return []92class IndexView(View):93 @transaction.atomic()94 def get(self, request):95 sp1 = transaction.savepoint()96 try:97 start = time.time()98 skip = skip_apps()99 result_sets = [test_application(app)100 for app in settings.INSTALLED_APPS101 if app not in skip]102 finish = time.time()103 all_passed = functools.reduce(104 lambda x, y: x & y, [r.passed() for r in result_sets])105 num_test_classes = sum([r.num_test_classes for r in result_sets])106 num_tests_run = sum([r.num_tests_run for r in result_sets])107 num_tests_passed = sum([r.num_tests_passed for r in result_sets])108 num_tests_failed = sum([r.num_tests_failed for r in result_sets])109 num_tests_errored = sum([r.num_tests_errored for r in result_sets])110 failed_report = make_failed_report(result_sets)111 errored_report = make_errored_report(result_sets)112 http_status = 500113 if all_passed:114 status = "PASS"115 http_status = 200116 else:117 status = "FAIL"118 response = HttpResponse(119 status=http_status,120 content=plaintext_output(121 status, num_test_classes, num_tests_run,122 num_tests_passed, num_tests_failed,123 num_tests_errored, finish, start,124 failed_report, errored_report),125 content_type="text/plain")126 if ('HTTP_ACCEPT' in request.META and (127 'application/json' in request.META['HTTP_ACCEPT'])):128 response = HttpResponse(129 json.dumps(130 dict(131 status=status,132 test_classes=num_test_classes,133 tests_run=num_tests_run,134 tests_passed=num_tests_passed,135 tests_failed=num_tests_failed,136 tests_errored=num_tests_errored,137 failed_tests=functools.reduce(138 lambda x, y: x + y,139 [r.failed for r in result_sets]),140 errored_tests=functools.reduce(141 lambda x, y: x + y,142 [r.errored for r in result_sets]),143 time=(finish - start) * 1000,144 )),145 content_type="application/json",146 )147 finally:148 # always roll back the smoketest view149 transaction.savepoint_rollback(sp1)...
ErrorProp.py
Source:ErrorProp.py
1import math2class ErroredValue(object):3 def __init__(self, value, delta=0):4 self.value = value5 self.delta = delta6 def __add__(self, o):7 if type(o) != ErroredValue:8 o = ErroredValue(o)9 return ErroredValue((self.value+o.value), (((self.delta**2) + (o.delta**2))**0.5))10 def __radd__(self, o):11 return ErroredValue((o+self.value), (((self.delta**2) + 0)**0.5))12 def __radd__(self, o):13 return ErroredValue((o+self.value), (((self.delta**2) + 0)**0.5))14 def __sub__(self, o):15 if o is self: return ErroredValue(0)16 if type(o) != ErroredValue:17 o = ErroredValue(o)18 return ErroredValue((self.value-o.value), (((self.delta**2) + (o.delta**2))**0.5))19 def __rsub__(self, o):20 return ErroredValue((o-self.value), (((self.delta**2) + 0)**0.5))21 def __rsub__(self, o):22 return ErroredValue((o-self.value), (((self.delta**2) + 0)**0.5))23 def __mul__(self, o):24 if type(o) != ErroredValue:25 o = ErroredValue(o)26 return ErroredValue((self.value*o.value), (self.value*o.value)*(((self.delta/self.value)**2 + (o.delta/o.value)**2)**0.5))27 def __rmul__(self, o):28 return ErroredValue((o*self.value), (o*self.value)*(((self.delta/self.value)**2 + 0)**0.5))29 30 def __truediv__(self, o):31 if self is o: return ErroredValue(1)32 if type(o) != ErroredValue:33 o = ErroredValue(o)34 return ErroredValue((self.value/o.value), (self.value/o.value)*(((self.delta/self.value)**2 + (o.delta/o.value)**2)**0.5))35 def __rtruediv__(self,o):36 return ErroredValue((o/self.value), (o/self.value)*(((self.delta/self.value)**2)**0.5))37 # https://physics.stackexchange.com/questions/411879/how-to-calculate-the-percentage-error-of-ex-if-percentage-error-in-measuring38 def __rpow__(self, a):39 return ErroredValue(a**(self.value), (0.5**self.value)*math.log(a, math.e)*self.delta)40 def __str__(self):41 return f'{self.value:.6f}±{self.delta:.6f}'42 def __repr__(self):43 return f'<ErroredValue {self.value:.6f}±{self.delta:.6f} at {hex(id(self))}>'44 @property45 def percentDelta(self):46 return self.delta/self.value47 @staticmethod48 def ln(a):...
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!!