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_editStoppedRule(self): print('=== Edit of a stopped rule test ===') ruleNumber = 0 # Edit the first rule print('Open the rule edit modal') rulesTable = dashboard.automation.waitRulesTableHasNRules( self.browser, 1) tools.waitUntil(lambda: dashboard.automation.getRuleEditButton( rulesTable, ruleNumber).is_enabled()) dashboard.automation.getRuleEditButton(rulesTable, ruleNumber).click() print('Change rule description') ruleNewDescription = "This is the new rule description" editRuleModal = dashboard.automation.waitEditRuleModal(self.browser) editRuleModal.setRuleDescription(ruleNewDescription) editRuleModal.ok() print('Check modified rule') notification.waitText( self.browser, notification.Type.Success, i18n.get()["modals"]["dashboard"]["sub-windows"] ["automation-center"]["ruleSuccessfullyUpdated"]) rulesTable = dashboard.automation.waitRulesTableHasNRules( self.browser, 1) ruleDatas = dashboard.automation.getRuleDatas(rulesTable, ruleNumber) tools.waitUntil(lambda: len(ruleDatas[1].text) > 0) self.assertEqual(ruleDatas[1].text, ruleNewDescription) self.assertEqual( dashboard.automation.getRuleState(rulesTable, ruleNumber), dashboard.automation.RuleState.Stopped) self.assertFalse( dashboard.automation.getRuleAutoStartState(rulesTable, ruleNumber))
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 checkCreateErroneousRule(self, ruleName, ruleDescription, ruleCode, ruleLog): print ' Check notifications' notification.waitText(self.browser, notification.Type.Success, i18n.get()["modals"]["dashboard"]["sub-windows"]["automation-center"]["ruleSuccessfullyCreated"]) notification.waitSubText(self.browser, notification.Type.Error, i18n.get()["eventLogger"]["RuleFailed"].replace("__who__", ruleName)) print ' Check rule was inserted in rules table' rulesTable = dashboard.automation.waitRulesTableHasNRules(self.browser, 1) ruleNumber = 0 print ' Check rule data in rules table' self.assertEqual(len(dashboard.automation.getRuleDatas(rulesTable, ruleNumber)), 5) self.assertEqual(dashboard.automation.getRuleName(rulesTable, ruleNumber), ruleName) self.assertEqual(dashboard.automation.getRuleDescription(rulesTable, ruleNumber), ruleDescription) self.assertTrue(dashboard.automation.getRuleAutoStart(rulesTable, ruleNumber)) buttons = dashboard.automation.getRuleButtons(rulesTable, ruleNumber) self.assertEqual(len(buttons), 4) self.assertTrue(tools.waitUntil(lambda: dashboard.automation.getRuleStartStopButton(rulesTable, ruleNumber).get_attribute("class"), "btn btn-enableDisable btn-success")) self.assertEqual(dashboard.automation.getRuleEditButton(rulesTable, ruleNumber).get_attribute("class"), "btn btn-edit btn-primary") self.assertEqual(dashboard.automation.getRuleRemoveButton(rulesTable, ruleNumber).get_attribute("class"), "btn btn-delete btn-danger") self.assertTrue(tools.waitUntil(lambda: dashboard.automation.getRuleState(rulesTable, ruleNumber) == dashboard.automation.RuleState.Error)) print ' Check rule was created on disk (corresponding script file)' self.assertTrue(scripts.checkLocalRuleCodeById(1, ruleCode)) self.assertTrue(tools.waitUntil(lambda: scripts.checkLocalRuleLogById(1, ruleLog)))
def doTest_removeRule(self, initialConditionsFct): print(' Open rules dashboard') dashboard.open(self.browser) dashboard.openAutomation(self.browser) ruleNumber = 0 print(' Get rule table') rulesTable = dashboard.automation.waitRulesTableHasNRules( self.browser, 1) removeButton = dashboard.automation.getRuleRemoveButton( rulesTable, ruleNumber) initialConditionsFct(rulesTable, ruleNumber) print(' Remove rule') removeButton.click() confirmationModal = modals.waitOkCancelModal(self.browser) confirmationModal.ok() print(' Expect notification') notification.waitText( self.browser, notification.Type.Success, i18n.get()["modals"]["dashboard"]["sub-windows"] ["automation-center"]["ruleDeleted"]) print(' Check table was updated') self.assertTrue( tools.waitUntil( lambda: dashboard.automation.getRuleNumberInTable( self.browser, rulesTable) == 0, 5))
def test_editRunningRule(self): print '=== Edit of a running rule test ===' ruleNumber = 0 print 'Start the rule' rulesTable = dashboard.automation.waitRulesTableHasNRules(self.browser, 1) tools.waitUntil(lambda: dashboard.automation.getRuleStartStopButton(rulesTable, ruleNumber).is_enabled()) dashboard.automation.getRuleStartStopButton(rulesTable, ruleNumber).click() WebDriverWait(self.browser, 10).until(lambda driver: dashboard.automation.getRuleState(rulesTable, ruleNumber) is dashboard.automation.RuleState.Running) # Edit the first rule print 'Open the rule edit modal' dashboard.automation.getRuleEditButton(rulesTable, ruleNumber).click() # Modify rule description print 'Change rule description' ruleNewDescription = "This is the new rule description" editRuleModal = dashboard.automation.waitEditRuleModal(self.browser) editRuleModal.setRuleDescription(ruleNewDescription) editRuleModal.ok() # Check modified rule print 'Check modified rule' notification.waitText(self.browser, notification.Type.Success, i18n.get()["modals"]["dashboard"]["sub-windows"]["automation-center"]["ruleSuccessfullyUpdated"]) rulesTable = dashboard.automation.waitRulesTableHasNRules(self.browser, 1) ruleDatas = dashboard.automation.getRuleDatas(rulesTable, ruleNumber) tools.waitUntil(lambda: len(ruleDatas[1].text) > 0) self.assertEqual(ruleDatas[1].text, ruleNewDescription) self.assertEqual(dashboard.automation.getRuleState(rulesTable, ruleNumber), dashboard.automation.RuleState.Running) self.assertFalse(dashboard.automation.getRuleAutoStart(rulesTable, ruleNumber))
def checkCreateErroneousRule(self, ruleName, ruleDescription, ruleCode, ruleLog): print (' Check notifications') notification.waitText(self.browser, notification.Type.Success, i18n.get()["modals"]["dashboard"]["sub-windows"]["automation-center"]["ruleSuccessfullyCreated"]) notification.waitSubText(self.browser, notification.Type.Error, i18n.get()["eventLogger"]["RuleFailed"].replace("{{who}}", ruleName)) print (' Check rule was inserted in rules table') rulesTable = dashboard.automation.waitRulesTableHasNRules(self.browser, 1) ruleNumber = 0 print (' Check rule data in rules table') self.assertEqual(len(dashboard.automation.getRuleDatas(rulesTable, ruleNumber)), 5) self.assertEqual(dashboard.automation.getRuleName(rulesTable, ruleNumber), ruleName) self.assertEqual(dashboard.automation.getRuleDescription(rulesTable, ruleNumber), ruleDescription) self.assertTrue(dashboard.automation.getRuleAutoStartState(rulesTable, ruleNumber)) buttons = dashboard.automation.getRuleButtons(rulesTable, ruleNumber) self.assertEqual(len(buttons), 5) self.assertTrue(tools.waitUntil(lambda: dashboard.automation.getRuleStartStopButton(rulesTable, ruleNumber).get_attribute("class"), "btn btn-enableDisable btn-success")) self.assertEqual(dashboard.automation.getRuleStartStopButton(rulesTable, ruleNumber).get_attribute("class"), "btn btn-startStop btn-success") self.assertEqual(dashboard.automation.getRuleEditButton(rulesTable, ruleNumber).get_attribute("class"), "btn btn-edit btn-primary") self.assertEqual(dashboard.automation.getRuleDuplicateButton(rulesTable, ruleNumber).get_attribute("class"), "btn btn-duplicate btn-primary") self.assertEqual(dashboard.automation.getRuleRemoveButton(rulesTable, ruleNumber).get_attribute("class"), "btn btn-delete btn-danger") self.assertTrue(tools.waitUntil(lambda: dashboard.automation.getRuleState(rulesTable, ruleNumber) == dashboard.automation.RuleState.Error)) print (' Check rule was created on disk (corresponding script file)') self.assertTrue(scripts.checkLocalRuleCodeById(1, ruleCode)) self.assertTrue(tools.waitUntil(lambda: scripts.checkLocalRuleLogById(1, ruleLog)))
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 checkCreateOkRule(self, ruleName, ruleDescription, ruleCode, ruleLog): print ' Check notification' notification.waitText( self.browser, notification.Type.Success, i18n.get()["modals"]["dashboard"]["sub-windows"] ["automation-center"]["ruleSuccessfullyCreated"]) print ' Check rule was inserted in rules table' rulesTable = dashboard.automation.waitRulesTableHasNRules( self.browser, 1) ruleNumber = 0 print ' Check rule data in rules table' self.assertEqual( len(dashboard.automation.getRuleDatas(rulesTable, ruleNumber)), 5) self.assertEqual( dashboard.automation.getRuleName(rulesTable, ruleNumber), ruleName) self.assertEqual( dashboard.automation.getRuleDescription(rulesTable, ruleNumber), ruleDescription) self.assertTrue( dashboard.automation.getRuleAutoStart(rulesTable, ruleNumber)) buttons = dashboard.automation.getRuleButtons(rulesTable, ruleNumber) self.assertEqual(len(buttons), 4) self.assertEqual( dashboard.automation.getRuleStartStopButton( rulesTable, ruleNumber).get_attribute("class"), "btn btn-startStop btn-warning") self.assertEqual( dashboard.automation.getRuleEditButton( rulesTable, ruleNumber).get_attribute("class"), "btn btn-edit btn-primary") self.assertEqual( dashboard.automation.getRuleRemoveButton( rulesTable, ruleNumber).get_attribute("class"), "btn btn-delete btn-danger") self.assertEqual( dashboard.automation.getRuleState(rulesTable, ruleNumber), dashboard.automation.RuleState.Running) print ' Check rule was created on disk (corresponding script file)' self.assertTrue(scripts.checkLocalRuleCodeById(1, ruleCode)) self.assertTrue( tools.waitUntil(lambda: scripts.checkLocalRuleLogById(1, ruleLog)))
def doTest_removeRule(self, initialConditionsFct): print ' Open rules dashboard' dashboard.open(self.browser) dashboard.openAutomation(self.browser) ruleNumber = 0 print ' Get rule table' rulesTable = dashboard.automation.waitRulesTableHasNRules(self.browser, 1) removeButton = dashboard.automation.getRuleRemoveButton(rulesTable, ruleNumber) initialConditionsFct(rulesTable, ruleNumber) print ' Remove rule' removeButton.click() confirmationModal = dashboard.automation.waitRemoveRuleConfirmationModal(self.browser) confirmationModal.ok() print ' Expect notification' notification.waitText(self.browser, notification.Type.Success, i18n.get()["modals"]["dashboard"]["sub-windows"]["automation-center"]["ruleDeleted"]) print ' Check table was updated' self.assertTrue(tools.waitUntil(lambda: dashboard.automation.getRuleNumberInTable(self.browser, rulesTable) == 0, 5))