How to use triggered method in uiautomator

Best Python code snippet using uiautomator

Ui_MainWindowWidgetConnections.py

Source:Ui_MainWindowWidgetConnections.py Github

copy

Full Screen

...16 Create all connects for all Main Window widgets used in menus and toolbars.17 @param win: NE1's mainwindow object.18 @type win: U{B{QMainWindow}<http://doc.trolltech.com/4/qmainwindow.html>}19 """20 win.connect(win.dispBallAction,SIGNAL("triggered()"),win.dispBall)21 win.connect(win.dispDefaultAction,SIGNAL("triggered()"),win.dispDefault)22 win.connect(win.dispElementColorSettingsAction,SIGNAL("triggered()"),win.dispElementColorSettings)23 win.connect(win.dispInvisAction,SIGNAL("triggered()"),win.dispInvis)24 win.connect(win.dispLightingAction,SIGNAL("triggered()"),win.dispLighting)25 win.connect(win.dispLinesAction,SIGNAL("triggered()"),win.dispLines)26 win.connect(win.dispObjectColorAction,SIGNAL("triggered()"),win.dispObjectColor)27 win.connect(win.resetChunkColorAction,SIGNAL("triggered()"),win.dispResetChunkColor)28 win.connect(win.dispResetAtomsDisplayAction,SIGNAL("triggered()"),win.dispResetAtomsDisplay)29 win.connect(win.dispShowInvisAtomsAction,SIGNAL("triggered()"),win.dispShowInvisAtoms)30 win.connect(win.dispTubesAction,SIGNAL("triggered()"),win.dispTubes)31 win.connect(win.dispCPKAction,SIGNAL("triggered()"),win.dispCPK)32 win.connect(win.dispHideAction,SIGNAL("triggered()"),win.dispHide)33 win.connect(win.dispUnhideAction,SIGNAL("triggered()"),win.dispUnhide)34 win.connect(win.dispHybridAction,SIGNAL("triggered()"),win.dispHybrid)35 win.connect(win.editAutoCheckpointingAction,SIGNAL("toggled(bool)"),win.editAutoCheckpointing)36 win.connect(win.editClearUndoStackAction,SIGNAL("triggered()"),win.editClearUndoStack)37 win.connect(win.editCopyAction,SIGNAL("triggered()"),win.editCopy)38 win.connect(win.editCutAction,SIGNAL("triggered()"),win.editCut)39 win.connect(win.editDeleteAction,SIGNAL("triggered()"),win.killDo)40 win.connect(win.editMakeCheckpointAction,SIGNAL("triggered()"),win.editMakeCheckpoint)41 win.connect(win.editPasteAction,SIGNAL("triggered()"),win.editPaste)42 43 win.connect(win.editDnaDisplayStyleAction, 44 SIGNAL("triggered()"), 45 win.enterDnaDisplayStyleCommand)46 win.connect(win.editProteinDisplayStyleAction, 47 SIGNAL("triggered()"), 48 win.enterProteinDisplayStyleCommand)49 50 win.connect(win.editRenameAction,SIGNAL("triggered()"),win.editRename)51 win.connect(win.editRenameObjectsAction,SIGNAL("triggered()"),win.editRenameSelectedObjects)52 win.connect(win.editAddSuffixAction,SIGNAL("triggered()"),win.editAddSuffix)53 win.connect(win.pasteFromClipboardAction, 54 SIGNAL("triggered()"),55 win.editPasteFromClipboard )56 win.connect(win.partLibAction, 57 SIGNAL("triggered()"),58 win.insertPartFromPartLib)59 win.connect(win.viewFullScreenAction, 60 SIGNAL("toggled(bool)"), 61 win.setViewFullScreen)62 win.connect(win.viewSemiFullScreenAction, 63 SIGNAL("toggled(bool)"), 64 win.setViewSemiFullScreen)65 win.connect(win.viewReportsAction, 66 SIGNAL("toggled(bool)"), 67 win.reportsDockWidget.toggle)68 win.connect(win.viewRulersAction, 69 SIGNAL("toggled(bool)"), 70 win.toggleRulers)71 #Urmi background color chooser option 08052272 win.connect(win.colorSchemeAction, 73 SIGNAL("triggered()"), 74 win.colorSchemeCommand)75 win.connect(win.lightingSchemeAction,76 SIGNAL("triggered()"),77 win.lightingSchemeCommand)78 79 win.connect(win.editPrefsAction,SIGNAL("triggered()"),win.editPrefs)80 win.connect(win.editRedoAction,SIGNAL("triggered()"),win.editRedo)81 win.connect(win.editUndoAction,SIGNAL("triggered()"),win.editUndo)82 #= Connections for the "File" menu and toolbar widgets.83 win.connect(win.fileCloseAction,84 SIGNAL("triggered()"),85 win.fileClose)86 win.connect(win.fileExitAction,87 SIGNAL("triggered()"),88 win.close)89 win.connect(win.fileOpenAction,90 SIGNAL("triggered()"),91 win.fileOpen)92 win.connect(win.fileSaveAction,93 SIGNAL("triggered()"),94 win.fileSave)95 win.connect(win.fileSaveAsAction,96 SIGNAL("triggered()"),97 win.fileSaveAs)98 win.connect(win.fileSaveSelectionAction,99 SIGNAL("triggered()"),100 win.fileSaveSelection)101 win.connect(win.fileSetWorkingDirectoryAction,102 SIGNAL("triggered()"), 103 win.fileSetWorkingDirectory)104 win.connect(win.fileInsertMmpAction,105 SIGNAL("triggered()"),106 win.fileInsertMmp)107 win.connect(win.fileInsertPdbAction,108 SIGNAL("triggered()"),109 win.fileInsertPdb)110 win.connect(win.fileExportQuteMolXPdbAction,111 SIGNAL("triggered()"),112 win.fileExportQuteMolXPdb)113 win.connect(win.fileExportPdbAction,114 SIGNAL("triggered()"),115 win.fileExportPdb)116 117 win.connect(win.fileFetchPdbAction,118 SIGNAL("triggered()"),119 win.fileFetchPdb)120 121 win.connect(win.fileExportJpgAction,122 SIGNAL("triggered()"),123 win.fileExportJpg)124 win.connect(win.fileExportPngAction,125 SIGNAL("triggered()"),126 win.fileExportPng)127 win.connect(win.fileExportPovAction,128 SIGNAL("triggered()"),129 win.fileExportPov)130 win.connect(win.fileExportAmdlAction,131 SIGNAL("triggered()"),132 win.fileExportAmdl)133 win.connect(win.helpTutorialsAction,SIGNAL("triggered()"),win.helpTutorials)134 win.connect(win.helpAboutAction,SIGNAL("triggered()"),win.helpAbout)135 win.connect(win.helpGraphicsCardAction,SIGNAL("triggered()"),win.helpGraphicsCard)136 win.connect(win.helpKeyboardShortcutsAction,SIGNAL("triggered()"),win.helpKeyboardShortcuts)137 win.connect(win.helpSelectionShortcutsAction,SIGNAL("triggered()"),win.helpSelectionShortcuts)138 win.connect(win.helpMouseControlsAction,SIGNAL("triggered()"),win.helpMouseControls)139 win.connect(win.helpWhatsThisAction,SIGNAL("triggered()"),win.helpWhatsThis)140 win.connect(win.buildDnaAction,SIGNAL("triggered()"),win.activateDnaTool)141 win.connect(win.buildNanotubeAction,SIGNAL("triggered()"),win.activateNanotubeTool)142 win.connect(win.insertCommentAction,SIGNAL("triggered()"),win.insertComment)143 win.connect(win.nanotubeGeneratorAction,SIGNAL("triggered()"),win.generateNanotube)144 win.connect(win.insertGrapheneAction,SIGNAL("triggered()"),win.insertGraphene)145 win.connect(win.jigsAnchorAction,SIGNAL("triggered()"),win.makeAnchor)146 win.connect(win.jigsAngleAction,SIGNAL("triggered()"),win.makeMeasureAngle)147 win.connect(win.jigsAtomSetAction,SIGNAL("triggered()"),win.makeAtomSet)148 win.connect(win.jigsDihedralAction,SIGNAL("triggered()"),win.makeMeasureDihedral)149 win.connect(win.jigsDistanceAction,SIGNAL("triggered()"),win.makeMeasureDistance)150 win.connect(win.jigsESPImageAction,SIGNAL("triggered()"),win.makeESPImage)151 win.connect(win.jigsGamessAction,SIGNAL("triggered()"),win.makeGamess)152 win.connect(win.jigsGridPlaneAction,SIGNAL("triggered()"),win.makeGridPlane)153 win.connect(win.referencePlaneAction,SIGNAL("triggered()"),154 win.createPlane)155 win.connect(win.referenceLineAction,SIGNAL("triggered()"),156 win.createPolyLine)157 win.connect(win.jigsLinearMotorAction,158 SIGNAL("triggered()"),159 win.makeLinearMotor)160 win.connect(win.jigsMotorAction,161 SIGNAL("triggered()"),162 win.makeRotaryMotor)163 win.connect(win.jigsStatAction,SIGNAL("triggered()"),win.makeStat)164 win.connect(win.jigsThermoAction,SIGNAL("triggered()"),win.makeThermo)165 win.connect(win.modifyAlignCommonAxisAction,SIGNAL("triggered()"),win.modifyAlignCommonAxis)166 win.connect(win.modifyCenterCommonAxisAction,SIGNAL("triggered()"),win.modifyCenterCommonAxis)167 win.connect(win.modifyDehydrogenateAction,SIGNAL("triggered()"),win.modifyDehydrogenate)168 win.connect(win.modifyDeleteBondsAction,SIGNAL("triggered()"),win.modifyDeleteBonds)169 win.connect(win.modifyHydrogenateAction,SIGNAL("triggered()"),win.modifyHydrogenate)170 win.connect(win.modifyInvertAction,SIGNAL("triggered()"),win.modifyInvert)171 win.connect(win.modifyMergeAction,SIGNAL("triggered()"),win.modifyMerge)172 win.connect(win.makeChunkFromSelectedAtomsAction,173 SIGNAL("triggered()"),win.makeChunkFromAtom)174 win.connect(win.modifyAdjustAllAction,SIGNAL("triggered()"),win.modifyAdjustAll)175 win.connect(win.modifyAdjustSelAction,SIGNAL("triggered()"),win.modifyAdjustSel)176 win.connect(win.modifyPassivateAction,SIGNAL("triggered()"),win.modifyPassivate)177 win.connect(win.modifySeparateAction,SIGNAL("triggered()"),win.modifySeparate)178 win.connect(win.modifyStretchAction,SIGNAL("triggered()"),win.modifyStretch)179 win.connect(win.panToolAction,SIGNAL("toggled(bool)"),win.panTool)180 win.connect(win.rotateToolAction,SIGNAL("toggled(bool)"),win.rotateTool)181 win.connect(win.saveNamedViewAction,SIGNAL("triggered()"),win.saveNamedView)182 win.connect(win.selectAllAction,SIGNAL("triggered()"),win.selectAll)183 win.connect(win.selectConnectedAction,SIGNAL("triggered()"),win.selectConnected)184 win.connect(win.selectContractAction,SIGNAL("triggered()"),win.selectContract)185 win.connect(win.selectDoublyAction,SIGNAL("triggered()"),win.selectDoubly)186 win.connect(win.selectExpandAction,SIGNAL("triggered()"),win.selectExpand)187 win.connect(win.selectInvertAction,SIGNAL("triggered()"),win.selectInvert)188 win.connect(win.selectNoneAction,SIGNAL("triggered()"),win.selectNone)189 win.connect(win.selectLockAction,SIGNAL("toggled(bool)"),win.selectLock)190 191 ##win.connect(win.helpTipAction,SIGNAL("triggered()"), win.toggleQuickHelpTip)192 win.connect(win.viewOrientationAction,SIGNAL("toggled(bool)"),win.showOrientationWindow) #ninad061114193 ##When Standard Views button is clicked, show its QMenu.-- By default, nothing happens if you click on the 194 ##toolbutton with submenus. The menus are displayed only when you click on the small downward arrow 195 ## of the tool button. Therefore the following slot is added. Also QWidgetAction is used 196 ## for it to add this feature (see Ui_ViewToolBar for details) ninad 070109 197 win.connect(win.standardViews_btn,SIGNAL("pressed()"),win.showStandardViewsMenu)198 win.connect(win.viewBackAction,SIGNAL("triggered()"),win.viewBack)199 win.connect(win.viewBottomAction,SIGNAL("triggered()"),win.viewBottom)200 win.connect(win.setViewFitToWindowAction,SIGNAL("triggered()"),win.setViewFitToWindow)201 win.connect(win.viewFrontAction,SIGNAL("triggered()"),win.viewFront)202 win.connect(win.setViewHomeAction,SIGNAL("triggered()"),win.setViewHome)203 win.connect(win.setViewHomeToCurrentAction,SIGNAL("triggered()"),win.setViewHomeToCurrent)204 win.connect(win.viewLeftAction,SIGNAL("triggered()"),win.viewLeft)205 win.connect(win.viewRotateMinus90Action,SIGNAL("triggered()"),win.viewRotateMinus90)206 win.connect(win.viewNormalToAction,SIGNAL("triggered()"),win.viewNormalTo)207 win.connect(win.viewRotate180Action,SIGNAL("triggered()"),win.viewRotate180)208 win.connect(win.setViewOrthoAction,SIGNAL("triggered()"),win.setViewOrtho)209 win.connect(win.viewParallelToAction,SIGNAL("triggered()"),win.viewParallelTo)210 win.connect(win.setViewPerspecAction,SIGNAL("triggered()"),win.setViewPerspec)211 win.connect(win.viewRotatePlus90Action,SIGNAL("triggered()"),win.viewRotatePlus90)212 win.connect(win.setViewRecenterAction,SIGNAL("triggered()"),win.setViewRecenter)213 win.connect(win.viewRightAction,SIGNAL("triggered()"),win.viewRight)214 win.connect(win.viewTopAction,SIGNAL("triggered()"),win.viewTop)215 win.connect(win.simMoviePlayerAction,SIGNAL("triggered()"),win.simMoviePlayer)216 win.connect(win.simNanoHiveAction,SIGNAL("triggered()"),win.simNanoHive)217 win.connect(win.simPlotToolAction,SIGNAL("triggered()"),win.simPlot)218 win.connect(win.simSetupAction,SIGNAL("triggered()"),win.simSetup)219 win.connect(win.rosettaSetupAction,SIGNAL("triggered()"),win.rosettaSetup)220 win.connect(win.toolsCookieCutAction,SIGNAL("triggered()"),win.toolsCookieCut)221 win.connect(win.setStereoViewAction,SIGNAL("triggered()"),win.stereoSettings)222 win.connect(win.toolsDepositAtomAction,223 SIGNAL("triggered()"),224 win.toolsBuildAtoms)225 win.connect(win.toolsDoneAction,SIGNAL("triggered()"),win.toolsDone)226 win.connect(win.toolsExtrudeAction,SIGNAL("triggered()"),win.toolsExtrude)227 win.connect(win.toolsFuseChunksAction,SIGNAL("triggered()"),win.toolsFuseChunks)228 #Move and Rotate Components mode229 win.connect(win.toolsMoveMoleculeAction,SIGNAL("triggered()"),win.toolsMoveMolecule)230 win.connect(win.rotateComponentsAction,SIGNAL("triggered()"),win.toolsRotateComponents)231 win.connect(win.toolsSelectMoleculesAction,SIGNAL("triggered()"),win.toolsSelectMolecules)232 win.connect(win.zoomToAreaAction,SIGNAL("toggled(bool)"),win.zoomToArea)233 win.connect(win.zoomInOutAction,SIGNAL("toggled(bool)"),win.zoomInOut)234 win.connect(win.viewQuteMolAction,SIGNAL("triggered()"),win.viewQuteMol)235 win.connect(win.viewRaytraceSceneAction,SIGNAL("triggered()"),win.viewRaytraceScene)236 win.connect(win.insertPovraySceneAction,SIGNAL("triggered()"),win.insertPovrayScene)237 win.connect(win.dispSurfaceAction,SIGNAL("triggered()"),win.dispSurface)238 win.connect(win.dispCylinderAction,SIGNAL("triggered()"),win.dispCylinder)239 win.connect(win.dispDnaCylinderAction,SIGNAL("triggered()"),win.dispDnaCylinder)240 win.connect(win.simMinimizeEnergyAction,SIGNAL("triggered()"),win.simMinimizeEnergy)241 win.connect(win.fileImportOpenBabelAction,242 SIGNAL("triggered()"),243 win.fileOpenBabelImport)244 win.connect(win.fileImportIOSAction,245 SIGNAL("triggered()"),246 win.fileIOSImport)247 win.connect(win.fileExportOpenBabelAction,248 SIGNAL("triggered()"),249 win.fileOpenBabelExport)250 win.connect(win.fileExportIOSAction,251 SIGNAL("triggered()"),252 win.fileIOSExport)253 win.connect(win.viewIsometricAction,SIGNAL("triggered()"),win.viewIsometric)254 win.connect(win.modifyMirrorAction,SIGNAL("triggered()"),win.modifyMirror)255 win.connect(win.setViewZoomtoSelectionAction,SIGNAL("triggered()"),win.setViewZoomToSelection)256 # Atom Generator example for developers. Mark and Jeff. 2007-06-13257 #@ Jeff - add a link to the public wiki page when ready. Mark 2007-06-13.258 win.connect(win.insertAtomAction,SIGNAL("triggered()"),win.insertAtom)259 win.connect(win.insertPeptideAction,SIGNAL("triggered()"),win.activateProteinTool)260 QtCore.QObject.connect(win.fileExitAction,261 QtCore.SIGNAL("activated()"),...

Full Screen

Full Screen

common.py

Source:common.py Github

copy

Full Screen

1"""Common methods used across tests for TotalConnect."""2from unittest.mock import patch3from total_connect_client import ArmingState, ResultCode, ZoneStatus, ZoneType4from homeassistant.components.totalconnect.const import CONF_USERCODES, DOMAIN5from homeassistant.const import CONF_PASSWORD, CONF_USERNAME6from homeassistant.setup import async_setup_component7from tests.common import MockConfigEntry8LOCATION_ID = "123456"9DEVICE_INFO_BASIC_1 = {10 "DeviceID": "987654",11 "DeviceName": "test",12 "DeviceClassID": 1,13 "DeviceSerialNumber": "987654321ABC",14 "DeviceFlags": "PromptForUserCode=0,PromptForInstallerCode=0,PromptForImportSecuritySettings=0,AllowUserSlotEditing=0,CalCapable=1,CanBeSentToPanel=0,CanArmNightStay=0,CanSupportMultiPartition=0,PartitionCount=0,MaxPartitionCount=0,OnBoardingSupport=0,PartitionAdded=0,DuplicateUserSyncStatus=0,PanelType=8,PanelVariant=1,BLEDisarmCapable=0,ArmHomeSupported=0,DuplicateUserCodeCheck=1,CanSupportRapid=0,IsKeypadSupported=1,WifiEnrollmentSupported=0,IsConnectedPanel=0,ArmNightInSceneSupported=0,BuiltInCameraSettingsSupported=0,ZWaveThermostatScheduleDisabled=0,MultipleAuthorityLevelSupported=0,VideoOnPanelSupported=0,EnableBLEMode=0,IsPanelWiFiResetSupported=0,IsCompetitorClearBypass=0,IsNotReadyStateSupported=0,isArmStatusWithoutExitDelayNotSupported=0",15 "SecurityPanelTypeID": None,16 "DeviceSerialText": None,17}18DEVICE_LIST = [DEVICE_INFO_BASIC_1]19LOCATION_INFO_BASIC_NORMAL = {20 "LocationID": LOCATION_ID,21 "LocationName": "test",22 "SecurityDeviceID": "987654",23 "PhotoURL": "http://www.example.com/some/path/to/file.jpg",24 "LocationModuleFlags": "Security=1,Video=0,Automation=0,GPS=0,VideoPIR=0",25 "DeviceList": {"DeviceInfoBasic": DEVICE_LIST},26}27LOCATIONS = {"LocationInfoBasic": [LOCATION_INFO_BASIC_NORMAL]}28MODULE_FLAGS = "Some=0,Fake=1,Flags=2"29USER = {30 "UserID": "1234567",31 "Username": "username",32 "UserFeatureList": "Master=0,User Administration=0,Configuration Administration=0",33}34RESPONSE_AUTHENTICATE = {35 "ResultCode": ResultCode.SUCCESS.value,36 "SessionID": 1,37 "Locations": LOCATIONS,38 "ModuleFlags": MODULE_FLAGS,39 "UserInfo": USER,40}41RESPONSE_AUTHENTICATE_FAILED = {42 "ResultCode": ResultCode.BAD_USER_OR_PASSWORD.value,43 "ResultData": "test bad authentication",44}45PARTITION_DISARMED = {46 "PartitionID": "1",47 "ArmingState": ArmingState.DISARMED,48}49PARTITION_DISARMED2 = {50 "PartitionID": "2",51 "ArmingState": ArmingState.DISARMED,52}53PARTITION_ARMED_STAY = {54 "PartitionID": "1",55 "ArmingState": ArmingState.ARMED_STAY,56}57PARTITION_ARMED_STAY2 = {58 "PartitionID": "2",59 "ArmingState": ArmingState.DISARMED,60}61PARTITION_ARMED_AWAY = {62 "PartitionID": "1",63 "ArmingState": ArmingState.ARMED_AWAY,64}65PARTITION_ARMED_CUSTOM = {66 "PartitionID": "1",67 "ArmingState": ArmingState.ARMED_CUSTOM_BYPASS,68}69PARTITION_ARMED_NIGHT = {70 "PartitionID": "1",71 "ArmingState": ArmingState.ARMED_STAY_NIGHT,72}73PARTITION_ARMING = {74 "PartitionID": "1",75 "ArmingState": ArmingState.ARMING,76}77PARTITION_DISARMING = {78 "PartitionID": "1",79 "ArmingState": ArmingState.DISARMING,80}81PARTITION_TRIGGERED_POLICE = {82 "PartitionID": "1",83 "ArmingState": ArmingState.ALARMING,84}85PARTITION_TRIGGERED_FIRE = {86 "PartitionID": "1",87 "ArmingState": ArmingState.ALARMING_FIRE_SMOKE,88}89PARTITION_TRIGGERED_CARBON_MONOXIDE = {90 "PartitionID": "1",91 "ArmingState": ArmingState.ALARMING_CARBON_MONOXIDE,92}93PARTITION_UNKNOWN = {94 "PartitionID": "1",95 "ArmingState": "99999",96}97PARTITION_INFO_DISARMED = [PARTITION_DISARMED, PARTITION_DISARMED2]98PARTITION_INFO_ARMED_STAY = [PARTITION_ARMED_STAY, PARTITION_ARMED_STAY2]99PARTITION_INFO_ARMED_AWAY = [PARTITION_ARMED_AWAY]100PARTITION_INFO_ARMED_CUSTOM = [PARTITION_ARMED_CUSTOM]101PARTITION_INFO_ARMED_NIGHT = [PARTITION_ARMED_NIGHT]102PARTITION_INFO_ARMING = [PARTITION_ARMING]103PARTITION_INFO_DISARMING = [PARTITION_DISARMING]104PARTITION_INFO_TRIGGERED_POLICE = [PARTITION_TRIGGERED_POLICE]105PARTITION_INFO_TRIGGERED_FIRE = [PARTITION_TRIGGERED_FIRE]106PARTITION_INFO_TRIGGERED_CARBON_MONOXIDE = [PARTITION_TRIGGERED_CARBON_MONOXIDE]107PARTITION_INFO_UNKNOWN = [PARTITION_UNKNOWN]108PARTITIONS_DISARMED = {"PartitionInfo": PARTITION_INFO_DISARMED}109PARTITIONS_ARMED_STAY = {"PartitionInfo": PARTITION_INFO_ARMED_STAY}110PARTITIONS_ARMED_AWAY = {"PartitionInfo": PARTITION_INFO_ARMED_AWAY}111PARTITIONS_ARMED_CUSTOM = {"PartitionInfo": PARTITION_INFO_ARMED_CUSTOM}112PARTITIONS_ARMED_NIGHT = {"PartitionInfo": PARTITION_INFO_ARMED_NIGHT}113PARTITIONS_ARMING = {"PartitionInfo": PARTITION_INFO_ARMING}114PARTITIONS_DISARMING = {"PartitionInfo": PARTITION_INFO_DISARMING}115PARTITIONS_TRIGGERED_POLICE = {"PartitionInfo": PARTITION_INFO_TRIGGERED_POLICE}116PARTITIONS_TRIGGERED_FIRE = {"PartitionInfo": PARTITION_INFO_TRIGGERED_FIRE}117PARTITIONS_TRIGGERED_CARBON_MONOXIDE = {118 "PartitionInfo": PARTITION_INFO_TRIGGERED_CARBON_MONOXIDE119}120PARTITIONS_UNKNOWN = {"PartitionInfo": PARTITION_INFO_UNKNOWN}121ZONE_NORMAL = {122 "ZoneID": "1",123 "ZoneDescription": "Normal",124 "ZoneStatus": ZoneStatus.NORMAL,125 "PartitionId": "1",126}127ZONE_INFO = [ZONE_NORMAL]128ZONES = {"ZoneInfo": ZONE_INFO}129METADATA_DISARMED = {130 "Partitions": PARTITIONS_DISARMED,131 "Zones": ZONES,132 "PromptForImportSecuritySettings": False,133 "IsInACLoss": False,134 "IsCoverTampered": False,135 "Bell1SupervisionFailure": False,136 "Bell2SupervisionFailure": False,137 "IsInLowBattery": False,138}139METADATA_ARMED_STAY = METADATA_DISARMED.copy()140METADATA_ARMED_STAY["Partitions"] = PARTITIONS_ARMED_STAY141METADATA_ARMED_AWAY = METADATA_DISARMED.copy()142METADATA_ARMED_AWAY["Partitions"] = PARTITIONS_ARMED_AWAY143METADATA_ARMED_CUSTOM = METADATA_DISARMED.copy()144METADATA_ARMED_CUSTOM["Partitions"] = PARTITIONS_ARMED_CUSTOM145METADATA_ARMED_NIGHT = METADATA_DISARMED.copy()146METADATA_ARMED_NIGHT["Partitions"] = PARTITIONS_ARMED_NIGHT147METADATA_ARMING = METADATA_DISARMED.copy()148METADATA_ARMING["Partitions"] = PARTITIONS_ARMING149METADATA_DISARMING = METADATA_DISARMED.copy()150METADATA_DISARMING["Partitions"] = PARTITIONS_DISARMING151METADATA_TRIGGERED_POLICE = METADATA_DISARMED.copy()152METADATA_TRIGGERED_POLICE["Partitions"] = PARTITIONS_TRIGGERED_POLICE153METADATA_TRIGGERED_FIRE = METADATA_DISARMED.copy()154METADATA_TRIGGERED_FIRE["Partitions"] = PARTITIONS_TRIGGERED_FIRE155METADATA_TRIGGERED_CARBON_MONOXIDE = METADATA_DISARMED.copy()156METADATA_TRIGGERED_CARBON_MONOXIDE["Partitions"] = PARTITIONS_TRIGGERED_CARBON_MONOXIDE157METADATA_UNKNOWN = METADATA_DISARMED.copy()158METADATA_UNKNOWN["Partitions"] = PARTITIONS_UNKNOWN159RESPONSE_DISARMED = {160 "ResultCode": 0,161 "PanelMetadataAndStatus": METADATA_DISARMED,162 "ArmingState": ArmingState.DISARMED,163}164RESPONSE_ARMED_STAY = {165 "ResultCode": 0,166 "PanelMetadataAndStatus": METADATA_ARMED_STAY,167 "ArmingState": ArmingState.ARMED_STAY,168}169RESPONSE_ARMED_AWAY = {170 "ResultCode": 0,171 "PanelMetadataAndStatus": METADATA_ARMED_AWAY,172 "ArmingState": ArmingState.ARMED_AWAY,173}174RESPONSE_ARMED_CUSTOM = {175 "ResultCode": 0,176 "PanelMetadataAndStatus": METADATA_ARMED_CUSTOM,177 "ArmingState": ArmingState.ARMED_CUSTOM_BYPASS,178}179RESPONSE_ARMED_NIGHT = {180 "ResultCode": 0,181 "PanelMetadataAndStatus": METADATA_ARMED_NIGHT,182 "ArmingState": ArmingState.ARMED_STAY_NIGHT,183}184RESPONSE_ARMING = {185 "ResultCode": 0,186 "PanelMetadataAndStatus": METADATA_ARMING,187 "ArmingState": ArmingState.ARMING,188}189RESPONSE_DISARMING = {190 "ResultCode": 0,191 "PanelMetadataAndStatus": METADATA_DISARMING,192 "ArmingState": ArmingState.DISARMING,193}194RESPONSE_TRIGGERED_POLICE = {195 "ResultCode": 0,196 "PanelMetadataAndStatus": METADATA_TRIGGERED_POLICE,197 "ArmingState": ArmingState.ALARMING,198}199RESPONSE_TRIGGERED_FIRE = {200 "ResultCode": 0,201 "PanelMetadataAndStatus": METADATA_TRIGGERED_FIRE,202 "ArmingState": ArmingState.ALARMING_FIRE_SMOKE,203}204RESPONSE_TRIGGERED_CARBON_MONOXIDE = {205 "ResultCode": 0,206 "PanelMetadataAndStatus": METADATA_TRIGGERED_CARBON_MONOXIDE,207 "ArmingState": ArmingState.ALARMING_CARBON_MONOXIDE,208}209RESPONSE_UNKNOWN = {210 "ResultCode": 0,211 "PanelMetadataAndStatus": METADATA_UNKNOWN,212 "ArmingState": ArmingState.DISARMED,213}214RESPONSE_ARM_SUCCESS = {"ResultCode": ResultCode.ARM_SUCCESS.value}215RESPONSE_ARM_FAILURE = {"ResultCode": ResultCode.COMMAND_FAILED.value}216RESPONSE_DISARM_SUCCESS = {"ResultCode": ResultCode.DISARM_SUCCESS.value}217RESPONSE_DISARM_FAILURE = {218 "ResultCode": ResultCode.COMMAND_FAILED.value,219 "ResultData": "Command Failed",220}221RESPONSE_USER_CODE_INVALID = {222 "ResultCode": ResultCode.USER_CODE_INVALID.value,223 "ResultData": "testing user code invalid",224}225RESPONSE_SUCCESS = {"ResultCode": ResultCode.SUCCESS.value}226USERNAME = "username@me.com"227PASSWORD = "password"228USERCODES = {123456: "7890"}229CONFIG_DATA = {230 CONF_USERNAME: USERNAME,231 CONF_PASSWORD: PASSWORD,232 CONF_USERCODES: USERCODES,233}234CONFIG_DATA_NO_USERCODES = {CONF_USERNAME: USERNAME, CONF_PASSWORD: PASSWORD}235PARTITION_DETAILS_1 = {236 "PartitionID": 1,237 "ArmingState": ArmingState.DISARMED.value,238 "PartitionName": "Test1",239}240PARTITION_DETAILS_2 = {241 "PartitionID": 2,242 "ArmingState": ArmingState.DISARMED.value,243 "PartitionName": "Test2",244}245PARTITION_DETAILS = {"PartitionDetails": [PARTITION_DETAILS_1, PARTITION_DETAILS_2]}246RESPONSE_PARTITION_DETAILS = {247 "ResultCode": ResultCode.SUCCESS.value,248 "ResultData": "testing partition details",249 "PartitionsInfoList": PARTITION_DETAILS,250}251ZONE_DETAILS_NORMAL = {252 "PartitionId": "1",253 "Batterylevel": "-1",254 "Signalstrength": "-1",255 "zoneAdditionalInfo": None,256 "ZoneID": "1",257 "ZoneStatus": ZoneStatus.NORMAL,258 "ZoneTypeId": ZoneType.SECURITY,259 "CanBeBypassed": 1,260 "ZoneFlags": None,261}262ZONE_STATUS_INFO = [ZONE_DETAILS_NORMAL]263ZONE_DETAILS = {"ZoneStatusInfoWithPartitionId": ZONE_STATUS_INFO}264ZONE_DETAIL_STATUS = {"Zones": ZONE_DETAILS}265RESPONSE_GET_ZONE_DETAILS_SUCCESS = {266 "ResultCode": 0,267 "ResultData": "Success",268 "ZoneStatus": ZONE_DETAIL_STATUS,269}270TOTALCONNECT_REQUEST = (271 "homeassistant.components.totalconnect.TotalConnectClient.request"272)273async def setup_platform(hass, platform):274 """Set up the TotalConnect platform."""275 # first set up a config entry and add it to hass276 mock_entry = MockConfigEntry(domain=DOMAIN, data=CONFIG_DATA)277 mock_entry.add_to_hass(hass)278 responses = [279 RESPONSE_AUTHENTICATE,280 RESPONSE_PARTITION_DETAILS,281 RESPONSE_GET_ZONE_DETAILS_SUCCESS,282 RESPONSE_DISARMED,283 RESPONSE_DISARMED,284 ]285 with patch("homeassistant.components.totalconnect.PLATFORMS", [platform]), patch(286 TOTALCONNECT_REQUEST,287 side_effect=responses,288 ) as mock_request:289 assert await async_setup_component(hass, DOMAIN, {})290 assert mock_request.call_count == 5291 await hass.async_block_till_done()...

Full Screen

Full Screen

test_watchdog.py

Source:test_watchdog.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2# *****************************************************************************3# NICOS, the Networked Instrument Control System of the MLZ4# Copyright (c) 2009-2022 by the NICOS contributors (see AUTHORS)5#6# This program is free software; you can redistribute it and/or modify it under7# the terms of the GNU General Public License as published by the Free Software8# Foundation; either version 2 of the License, or (at your option) any later9# version.10#11# This program is distributed in the hope that it will be useful, but WITHOUT12# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS13# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more14# details.15#16# You should have received a copy of the GNU General Public License along with17# this program; if not, write to the Free Software Foundation, Inc.,18# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA19#20# Module authors:21# Georg Brandl <g.brandl@fz-juelich.de>22#23# *****************************************************************************24"""NICOS tests for the watchdog condition primitives."""25from nicos.services.watchdog.conditions import DelayedTrigger, Expression, \26 ConditionWithPrecondition27class DummyLog:28 def __init__(self):29 self.warnings = []30 def warning(self, msg, *args, **kwds):31 self.warnings.append(msg)32def test_expression():33 expr = Expression(DummyLog(), 'a and (b - 1)', 'sa and not sb')34 assert expr.interesting_keys() == set(['a', 'b'])35 # no values: not triggered36 assert not expr.triggered37 expr.new_setups(['sa'])38 # setup matches but still no values39 assert not expr.triggered40 expr.update(0, {'a': 1})41 # still not all values given42 assert not expr.triggered43 assert expr.is_expired(10)44 expr.update(0, {'a': 1, 'b': 2})45 # now we are triggered!46 assert expr.triggered47 assert not expr.is_expired(10)48 expr.update(0, {'a': 1, 'b': 1})49 assert not expr.triggered50 expr.new_setups([])51 expr.update(0, {'a': 1, 'b': 2})52 assert not expr.triggered53 assert not expr.log.warnings54 expr.update(0, {'a': 1, 'b': None})55 assert expr.log.warnings56def test_expired():57 expr = Expression(DummyLog(), 'a and b', '')58 # no values: not triggered, not expired59 assert not expr.triggered60 assert not expr.is_expired(0)61 expr.update(0, {'a': 1})62 # expires after 6 seconds63 assert not expr.is_expired(5)64 assert expr.is_expired(10)65 # needs to be still expired, not all values given66 expr.update(12, {'a': 1})67 assert expr.is_expired(12)68def test_delayed():69 expr = Expression(DummyLog(), 'a', '')70 delayed = DelayedTrigger(DummyLog(), expr, 5)71 assert delayed.interesting_keys() == set(['a'])72 assert not delayed.triggered73 delayed.update(0, {'a': 1})74 assert not delayed.triggered75 delayed.update(4, {'a': 1})76 assert not delayed.triggered77 delayed.update(5, {'a': 1})78 assert delayed.triggered79 delayed.update(6, {'a': 1})80 assert delayed.triggered81 delayed.update(7, {'a': 0})82 assert not delayed.triggered83 delayed.update(8, {'a': 1})84 assert not delayed.triggered85 delayed.tick(13)86 assert delayed.triggered87def test_precondition():88 pre = Expression(DummyLog(), 'pre', '')89 cond = Expression(DummyLog(), 'cond', '')90 cooldown = 091 combined = ConditionWithPrecondition(DummyLog(), pre, cond, cooldown)92 assert combined.interesting_keys() == set(['pre', 'cond'])93 combined.update(1, {'pre': 0, 'cond': 0})94 assert not combined.triggered95 combined.update(1, {'pre': 0, 'cond': 1})96 assert not combined.triggered97 combined.update(1, {'pre': 1, 'cond': 0})98 assert not combined.triggered99 combined.update(1, {'pre': 1, 'cond': 1})100 assert combined.triggered101 # if condition becomes true the instant precondition becomes false,102 # we are still happy103 combined.update(1, {'pre': 1, 'cond': 0})104 assert not combined.triggered105 combined.update(1, {'pre': 0, 'cond': 1})106 assert combined.triggered107def test_pre_with_cooldown():108 pre = Expression(DummyLog(), 'pre', '')109 pre = DelayedTrigger(DummyLog(), pre, 2)110 cond = Expression(DummyLog(), 'cond', '')111 cond = DelayedTrigger(DummyLog(), cond, 2)112 cooldown = 5113 combined = ConditionWithPrecondition(DummyLog(), pre, cond, cooldown)114 assert combined.interesting_keys() == set(['pre', 'cond'])115 combined.update(0, {'pre': 0, 'cond': 0})116 assert not combined.pre.triggered117 assert not combined.cond.triggered118 assert not combined.triggered119 combined.update(10, {'pre': 1, 'cond': 0})120 assert not combined.pre.triggered121 combined.update(15, {'pre': 1, 'cond': 0})122 assert combined.pre.triggered123 assert not combined.triggered124 combined.update(20, {'pre': 1, 'cond': 1})125 assert not combined.triggered126 combined.update(25, {'pre': 1, 'cond': 1})127 assert combined.triggered128 combined.update(30, {'pre': 0, 'cond': 1})129 assert combined.triggered130 combined.update(36, {'pre': 0, 'cond': 1})131 assert not combined.triggered132 combined.update(100, {'pre': 0, 'cond': 0})133 assert not combined.pre.triggered134 assert not combined.cond.triggered135 assert not combined.triggered136 combined.update(110, {'pre': 1, 'cond': 0})137 assert not combined.pre.triggered138 combined.update(115, {'pre': 1, 'cond': 0})139 assert combined.pre.triggered140 assert not combined.triggered141 combined.update(120, {'pre': 0, 'cond': 1})142 assert not combined.pre.triggered143 assert not combined.triggered144 combined.update(125, {'pre': 0, 'cond': 1})145 assert not combined.pre.triggered146 assert combined.triggered147 combined.update(126, {'pre': 0, 'cond': 1})148 assert not combined.pre.triggered...

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