def test_simpleQuery(self): print '=== Simple query test ===' pluginNumber = 0 print ' Select query' pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins( self.browser, 1) tools.waitUntil(lambda: dashboard.plugins.getPluginExtraCommandButton( pluginsTable, pluginNumber).is_enabled()) button = dashboard.plugins.getPluginExtraCommandButton( pluginsTable, pluginNumber) button.click() select = button.find_element_by_xpath( ".//following-sibling::ul[@class='dropdown-menu dropdown-extraqueries']" ) select.find_element_by_xpath( ".//li/a[@class='btn-extraQuery-simpleCommand']").click() notification.waitText( self.browser, notification.Type.Success, i18n.get()["core"]["plugins"]["extraquery"]["success"].replace( "{{extraquery}}", i18n.getPlugin("dev-fakePlugin")["extraQueries"] ["simpleCommand"]["name"]))
def test_changePluginStateMessageQuery(self): print '=== Query of change plugin state test ===' pluginNumber = 0 print ' Select query' pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins( self.browser, 1) tools.waitUntil(lambda: dashboard.plugins.getPluginExtraCommandButton( pluginsTable, pluginNumber).is_enabled()) button = dashboard.plugins.getPluginExtraCommandButton( pluginsTable, pluginNumber) button.click() select = button.find_element_by_xpath( ".//following-sibling::ul[@class='dropdown-menu dropdown-extraqueries']" ) select.find_element_by_xpath( ".//li/a[@class='btn-extraQuery-changePluginStateMessage']").click( ) modal = self.waitExtraQueryParameterModal() modal.setTextField( "plugins.dev-fakePlugin:extraQueries.changePluginStateMessage.commandData.newStateMessage", "message associated to plugin state") modal.ok() notification.waitText( self.browser, notification.Type.Success, i18n.get()["core"]["plugins"]["extraquery"]["success"].replace( "{{extraquery}}", i18n.getPlugin("dev-fakePlugin")["extraQueries"] ["changePluginStateMessage"]["name"]))
def test_asyncEQwithProgressionQuery(self): print '=== Query with progress following test ===' pluginNumber = 0 print ' Select query' pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins( self.browser, 1) tools.waitUntil(lambda: dashboard.plugins.getPluginExtraCommandButton( pluginsTable, pluginNumber).is_enabled()) button = dashboard.plugins.getPluginExtraCommandButton( pluginsTable, pluginNumber) button.click() select = button.find_element_by_xpath( ".//following-sibling::ul[@class='dropdown-menu dropdown-extraqueries']" ) select.find_element_by_xpath( ".//li/a[@class='btn-extraQuery-asyncEQwithProgression']").click() modal = self.waitExtraQueryParameterModal() modal.setFileField( "plugins.dev-fakePlugin:extraQueries.asyncEQwithProgression.commandData.fileContent", __file__) modal.ok() notification.waitText( self.browser, notification.Type.Success, i18n.get()["core"]["plugins"]["extraquery"]["success"].replace( "{{extraquery}}", i18n.getPlugin("dev-fakePlugin")["extraQueries"] ["asyncEQwithProgression"]["name"]), 20)
def test_dataBindingPluginCommandQuery(self): print '=== Query with data binding with plugin test ===' pluginNumber = 0 print ' Select query' pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins( self.browser, 1) tools.waitUntil(lambda: dashboard.plugins.getPluginExtraCommandButton( pluginsTable, pluginNumber).is_enabled()) button = dashboard.plugins.getPluginExtraCommandButton( pluginsTable, pluginNumber) button.click() select = button.find_element_by_xpath( ".//following-sibling::ul[@class='dropdown-menu dropdown-extraqueries']" ) select.find_element_by_xpath( ".//li/a[@class='btn-extraQuery-dataBindingPluginCommand']").click( ) modal = self.waitExtraQueryParameterModal() modal.setEnumField( "plugins.dev-fakePlugin:extraQueries.dataBindingPluginCommand.commandData.dynamicSection", 0) modal.ok() notification.waitText( self.browser, notification.Type.Success, i18n.get()["core"]["plugins"]["extraquery"]["success"].replace( "{{extraquery}}", i18n.getPlugin("dev-fakePlugin")["extraQueries"] ["dataBindingPluginCommand"]["name"]))
def test_driveEnumKeyword(self): print('=== Try to drive an enum keyword ===') print('ref Issues : #176') deviceName = u'fakeController1' keywordName = u'controllerValue' attachedPluginType = u'dev-FakePlugin' print(' Deploy device keywords') devicesTable = dashboard.devices.waitDevicesTable(self.browser) deviceId = dashboard.devices.waitDevicesTableHasDeviceNamed( self.browser, deviceName) deployButton = dashboard.devices.getDeployKeywordsButton( devicesTable, deviceId) deployButton.click() print(' Select keyword') tools.waitUntil( lambda: len(dashboard.devices.getKeywords(devicesTable)) == 1) keyword = dashboard.devices.getKeywords(devicesTable)[0] assert dashboard.devices.getKeywordName(keyword) == keywordName print(' Check that keyword is drivable') button = dashboard.devices.getCommandKeywordButton(keyword) assert button is not None print(' Set value to Run') button.click() setKeywordValueModal = dashboard.devices.waitSetValueKeywordModal( self.browser) translatedValue = i18n.getPlugin(attachedPluginType)['enumerations'][ 'EFakeControllerValues']['values']['Run'] setKeywordValueModal.setEnumValue(translatedValue) setKeywordValueModal.ok() assert tools.waitUntil(lambda: dashboard.devices.getKeywordTextValue( keyword) == translatedValue) print(' Set value to Left') button.click() setKeywordValueModal = dashboard.devices.waitSetValueKeywordModal( self.browser) translatedValue = i18n.getPlugin(attachedPluginType)['enumerations'][ 'EFakeControllerValues']['values']['Left'] setKeywordValueModal.setEnumValue(translatedValue) setKeywordValueModal.ok() assert tools.waitUntil(lambda: dashboard.devices.getKeywordTextValue( keyword) == translatedValue)
def checkCreatedPluginSequence(test, pluginInstanceName, pluginType, hasExtraCommand, hasLog): """ Check successfull plugin creation all-in-one sequence """ print ' Check notification' notification.waitText( test.browser, notification.Type.Success, i18n.get()["modals"]["configure-plugin"]["pluginSuccessfullyCreated"]) print ' Check plugins table' pluginsTable = waitPluginsTableHasNPlugins(test.browser, 1) pluginNumber = 0 test.assertEqual(len(getPluginDatas(pluginsTable, pluginNumber)), 5) test.assertEqual(getPluginName(pluginsTable, pluginNumber), pluginInstanceName) test.assertEqual( getPluginType(pluginsTable, pluginNumber).lstrip(), i18n.getPlugin(pluginType)["name"]) test.assertTrue(getPluginAutoStartState(pluginsTable, pluginNumber)) buttons = getPluginButtons(pluginsTable, pluginNumber) expectedButtonCount = 3 + (1 if hasExtraCommand else 0) + (1 if hasLog else 0) test.assertEqual(len(buttons), expectedButtonCount) buttonIndex = 0 startStopButton = getPluginStartStopButton(pluginsTable, pluginNumber) test.assertEqual(startStopButton, buttons[buttonIndex]) tools.waitUntil( lambda: "btn-warning" in startStopButton.get_attribute("class")) buttonIndex += 1 configureButton = getPluginConfigureButton(pluginsTable, pluginNumber) test.assertEqual(configureButton, buttons[buttonIndex]) test.assertIn("btn-primary", configureButton.get_attribute("class")) buttonIndex += 1 if hasExtraCommand: extraCommandButton = getPluginExtraCommandButton( pluginsTable, pluginNumber) test.assertEqual(extraCommandButton, buttons[buttonIndex]) test.assertIn("btn-success", extraCommandButton.get_attribute("class")) buttonIndex += 1 if hasLog: logButton = getPluginLogButton(pluginsTable, pluginNumber) test.assertEqual(logButton, buttons[buttonIndex]) test.assertIn("btn-info", logButton.get_attribute("class")) buttonIndex += 1 removeButton = getPluginRemoveButton(pluginsTable, pluginNumber) test.assertEqual(removeButton, buttons[buttonIndex]) test.assertIn("btn-danger", removeButton.get_attribute("class")) buttonIndex += 1 WebDriverWait(test.browser, 20).until(lambda browser: getPluginState( pluginsTable, pluginNumber) == PluginState.Running)
def checkCreatedPluginSequence(test, pluginInstanceName, pluginType, hasExtraCommand, hasLog): """ Check successfull plugin creation all-in-one sequence """ print ' Check notification' notification.waitText(test.browser, notification.Type.Success, i18n.get()["modals"]["configure-plugin"]["pluginSuccessfullyCreated"]) print ' Check plugins table' pluginsTable = waitPluginsTableHasNPlugins(test.browser, 1) pluginNumber = 0 test.assertEqual(len(getPluginDatas(pluginsTable, pluginNumber)), 5) test.assertEqual(getPluginName(pluginsTable, pluginNumber), pluginInstanceName) test.assertEqual(getPluginType(pluginsTable, pluginNumber).lstrip(), i18n.getPlugin(pluginType)["name"]) test.assertTrue(getPluginAutoStart(pluginsTable, pluginNumber)) buttons = getPluginButtons(pluginsTable, pluginNumber) expectedButtonCount = 3 + (1 if hasExtraCommand else 0) + (1 if hasLog else 0) test.assertEqual(len(buttons), expectedButtonCount) buttonIndex = 0 startStopButton = getPluginStartStopButton(pluginsTable, pluginNumber) test.assertEqual(startStopButton, buttons[buttonIndex]) tools.waitUntil(lambda: "btn-warning" in startStopButton.get_attribute("class")) buttonIndex +=1; configureButton = getPluginConfigureButton(pluginsTable, pluginNumber) test.assertEqual(configureButton, buttons[buttonIndex]) test.assertIn("btn-primary", configureButton.get_attribute("class")) buttonIndex +=1; if hasExtraCommand: extraCommandButton = getPluginExtraCommandButton(pluginsTable, pluginNumber) test.assertEqual(extraCommandButton, buttons[buttonIndex]) test.assertIn("btn-success", extraCommandButton.get_attribute("class")) buttonIndex +=1; if hasLog: logButton = getPluginLogButton(pluginsTable, pluginNumber) test.assertEqual(logButton, buttons[buttonIndex]) test.assertIn("btn-info", logButton.get_attribute("class")) buttonIndex +=1; removeButton = getPluginRemoveButton(pluginsTable, pluginNumber) test.assertEqual(removeButton, buttons[buttonIndex]) test.assertIn("btn-danger", removeButton.get_attribute("class")) buttonIndex +=1; WebDriverWait(test.browser, 20).until(lambda driver: getPluginState(pluginsTable, pluginNumber) == PluginState.Running)
def createPluginSequence(browser, pluginInstanceName, pluginType, setPluginConfigurationSequenceFct): """ Create plugin all-in-one sequence """ print ' Open plugin dashboard' dashboard.open(browser) dashboard.openPlugin(browser) print ' Create new plugin' tools.waitUntil(lambda: getCreatePluginButton(browser).is_enabled()) getCreatePluginButton(browser).click() newPluginModal = waitNewPluginModal(browser) newPluginModal.selectPlugin(i18n.getPlugin(pluginType)["name"]).click() newPluginModal.ok() setPluginConfigurationSequenceFct(pluginInstanceName)