Exemple #1
0
    def test_removePlugin(self):
        print '=== Remove plugin test ==='
        pluginNumber = 0

        pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins(
            self.browser, 1)
        self.assertTrue(
            tools.waitUntil(lambda: dashboard.plugins.getPluginRemoveButton(
                pluginsTable, pluginNumber).is_enabled()))
        removeButton = dashboard.plugins.getPluginRemoveButton(
            pluginsTable, pluginNumber)

        # TODO nettoyer
        if not tools.waitUntil(lambda: dashboard.plugins.getPluginState(
                pluginsTable, pluginNumber) is dashboard.plugins.PluginState.
                               Running):
            saveContext(self.browser)
            self.assertTrue(False)

        print 'Remove plugin'
        removeButton.click()
        confirmationModal = dashboard.plugins.waitRemovePluginConfirmationModal(
            self.browser)
        confirmationModal.ok()

        print 'Check table updated'
        self.assertTrue(
            tools.waitUntil(
                lambda: dashboard.plugins.getPluginNumberInTable(
                    self.browser, pluginsTable) == 0, 5))
    def test_createVirtualDevice(self):
        print('=== Manually virtual device creation test ===')
        deviceName = u'My virtual device'

        print('  Select virtual device')
        tools.waitUntil(lambda: dashboard.devices.getCreateDeviceButton(
            self.browser).is_enabled())
        dashboard.devices.getCreateDeviceButton(self.browser).click()
        newDeviceModal = dashboard.devices.waitNewDeviceModal(self.browser)
        newDeviceModal.selectVirtualDevice().click()
        newDeviceModal.ok()

        print('  Configure the virtual device')
        editVirtualDeviceModal = dashboard.devices.waitConfigureVirtualDeviceModal(
            self.browser)
        editVirtualDeviceModal.updateTextField('friendlyName', deviceName)
        # Device with the first capacity in the list
        # In the futur, it should be great to create all types of virtual devices
        print('  Click OK')
        editVirtualDeviceModal.ok()

        print('  Check created device')
        devicesTable = dashboard.devices.waitDevicesTable(self.browser)
        deviceId = dashboard.devices.waitDevicesTableHasDeviceNamed(
            self.browser, deviceName)
        deviceDatas = dashboard.devices.getDeviceDatas(devicesTable, deviceId)
        self.assertTrue(
            tools.waitUntil(lambda: dashboard.devices.getDeviceName(
                devicesTable, deviceId) == deviceName))
Exemple #3
0
   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)))
Exemple #4
0
   def test_startStopRule(self):
      print '=== start/stop rule test ==='

      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)
      startStopButton = dashboard.automation.getRuleStartStopButton(rulesTable, ruleNumber)
      
      self.assertEqual(dashboard.automation.getRuleState(rulesTable, ruleNumber), dashboard.automation.RuleState.Stopped)
      
      self.assertFalse(dashboard.automation.getRuleAutoStart(rulesTable, ruleNumber))
      
      print '  Start rule'
      self.assertTrue(tools.waitUntil(lambda: startStopButton.is_enabled()))
      startStopButton.click()
      WebDriverWait(self.browser, 10).until(lambda driver: dashboard.automation.getRuleState(rulesTable, ruleNumber) is dashboard.automation.RuleState.Running and startStopButton.is_enabled())

      print '  Stop rule'
      self.assertTrue(tools.waitUntil(lambda: startStopButton.is_enabled()))
      startStopButton.click()
      WebDriverWait(self.browser, 10).until(lambda driver: dashboard.automation.getRuleState(rulesTable, ruleNumber) is dashboard.automation.RuleState.Stopped and startStopButton.is_enabled())
Exemple #5
0
    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))
Exemple #6
0
   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)))
Exemple #7
0
    def doTest(self, ruleName, ruleDescription, ruleCode, checkRuleFct):
        print 'Open rules dashboard'
        dashboard.open(self.browser)
        dashboard.openAutomation(self.browser)

        print 'Create new rule'
        tools.waitUntil(lambda: dashboard.automation.getCreateRuleButton(
            self.browser).is_enabled())
        dashboard.automation.getCreateRuleButton(self.browser).click()
        newRuleModal = dashboard.automation.waitNewRuleModal(self.browser)

        print 'Select code'
        newRuleModal.getEditorSelectionButton('code').click()

        print 'Configure rule'
        editRuleModal = dashboard.automation.waitEditRuleModal(self.browser)
        print '  Set rule name'
        editRuleModal.setRuleName(ruleName)
        print '  Set rule description'
        editRuleModal.setRuleDescription(ruleDescription)

        print '  Set rule code'
        editRuleModal.getRuleCodeEditor().clear()
        editRuleModal.getRuleCodeEditor().writeCode(ruleCode)

        print 'Confirm'
        editRuleModal.ok()

        print 'Check created rule'
        checkRuleFct(ruleName, ruleDescription, ruleCode)
Exemple #8
0
   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 test_configurePlugin(self):
        print('=== Configure plugin test ===')
        pluginNumber = 0

        print('  Configure the first plugin')
        pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins(
            self.browser, 1)
        tools.waitUntil(lambda: dashboard.plugins.getPluginConfigureButton(
            pluginsTable, pluginNumber).is_enabled())
        dashboard.plugins.getPluginConfigureButton(pluginsTable,
                                                   pluginNumber).click()

        print('  Modify plugin name')
        pluginNewName = "This is the new plugin name"
        configurePluginModal = dashboard.plugins.waitConfigurePluginModal(
            self.browser)
        configurePluginModal.setPluginName(pluginNewName)
        configurePluginModal.ok()

        print('  Check modified plugin')
        pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins(
            self.browser, 1)
        pluginDatas = dashboard.plugins.getPluginDatas(pluginsTable,
                                                       pluginNumber)
        self.assertTrue(
            tools.waitUntil(lambda: dashboard.plugins.getPluginName(
                pluginsTable, pluginNumber) == pluginNewName))
        self.assertTrue(
            tools.waitUntil(lambda: dashboard.plugins.getPluginState(
                pluginsTable, pluginNumber) == dashboard.plugins.PluginState.
                            Running))
        self.assertTrue(
            dashboard.plugins.getPluginAutoStartState(pluginsTable,
                                                      pluginNumber))
Exemple #10
0
   def test_viewLogRunningRule(self):
      print '=== view log of running rule test ==='

      print '  Open rules dashboard'
      dashboard.open(self.browser)
      dashboard.openAutomation(self.browser)
      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 browser: dashboard.automation.getRuleState(rulesTable, ruleNumber) is dashboard.automation.RuleState.Running)
      
      print '  View log'
      dashboard.automation.getRuleLogButton(rulesTable, ruleNumber).click()

      print '  Check log'
      logModal = dashboard.automation.waitLogRuleModal(self.browser)
      self.assertIsNotNone(re.match(r'.*#### START ####.*', logModal.getLogContent(), re.DOTALL))

      print '  Clear log'
      logModal.getClearButton().click()
      confirmationModal = modals.waitOkCancelModal(self.browser)
      confirmationModal.ok()

      print '  Reopen log modal'
      dashboard.automation.getRuleLogButton(rulesTable, ruleNumber).click()
      self.assertIsNone(re.match(r'.*#### START ####.*', logModal.getLogContent(), re.DOTALL))

      print '  Close log modal'
      logModal.getConfirmButton().click()
Exemple #11
0
    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"]))
Exemple #12
0
    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"]))
Exemple #13
0
    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)
Exemple #14
0
    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"]))
Exemple #15
0
    def test_startStopPlugin(self):
        print '=== Start/stop plugin test ==='

        print 'Open plugins dashboard'
        dashboard.open(self.browser)
        dashboard.openPlugin(self.browser)
        pluginNumber = 0

        print 'Get plugins table'
        pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins(
            self.browser, 1)
        startStopButton = dashboard.plugins.getPluginStartStopButton(
            pluginsTable, pluginNumber)

        self.assertEqual(
            dashboard.plugins.getPluginState(pluginsTable, pluginNumber),
            dashboard.plugins.PluginState.Running)

        print 'Stop plugin'
        self.assertTrue(tools.waitUntil(lambda: startStopButton.is_enabled()))
        startStopButton.click()
        self.assertTrue(
            tools.waitUntil(lambda: dashboard.plugins.getPluginState(
                pluginsTable, pluginNumber) is dashboard.plugins.PluginState.
                            Stopped))

        print 'Start plugin'
        self.assertTrue(tools.waitUntil(lambda: startStopButton.is_enabled()))
        startStopButton.click()
        self.assertTrue(
            tools.waitUntil(lambda: dashboard.plugins.getPluginState(
                pluginsTable, pluginNumber) is dashboard.plugins.PluginState.
                            Running))
Exemple #16
0
   def doTest(self, ruleName, ruleDescription, ruleCode, checkRuleFct):
      print 'Open rules dashboard'
      dashboard.open(self.browser)
      dashboard.openAutomation(self.browser)

      print 'Create new rule'
      tools.waitUntil(lambda: dashboard.automation.getCreateRuleButton(self.browser).is_enabled())
      dashboard.automation.getCreateRuleButton(self.browser).click()
      newRuleModal = dashboard.automation.waitNewRuleModal(self.browser)
      
      print 'Select code'
      newRuleModal.getEditorSelectionButton('code').click()

      print 'Configure rule'
      editRuleModal = dashboard.automation.waitEditRuleModal(self.browser)
      print '  Set rule name'
      editRuleModal.setRuleName(ruleName)
      print '  Set rule description'
      editRuleModal.setRuleDescription(ruleDescription)
         
      print '  Set rule code'
      editRuleModal.getRuleCodeEditor().clear()
      editRuleModal.getRuleCodeEditor().writeCode(ruleCode)


      print 'Confirm'
      editRuleModal.ok()
      
      
      print 'Check created rule'
      checkRuleFct(ruleName, ruleDescription, ruleCode)
Exemple #17
0
    def test_createDevice(self):
        print '=== Manually device creation test ==='
        deviceName = u'My device'
        attachedPluginInstance = u'My fakePlugin instance'

        print '  Create the device'
        tools.waitUntil(lambda: dashboard.devices.getCreateDeviceButton(
            self.browser).is_enabled())
        dashboard.devices.getCreateDeviceButton(self.browser).click()
        newDeviceModal = dashboard.devices.waitNewDeviceModal(self.browser)
        newDeviceModal.selectAttachedPlugin(attachedPluginInstance).click()
        newDeviceModal.ok()

        print '  Configure the device'
        editDeviceModal = dashboard.devices.waitConfigureManuallyDeviceModal(
            self.browser)
        editDeviceModal.setDeviceName(deviceName)
        print '  Click OK'
        editDeviceModal.ok()

        print '  Check created device'
        devicesTable = dashboard.devices.waitDevicesTable(self.browser)
        deviceId = dashboard.devices.waitDevicesTableHasDeviceNamed(
            self.browser, deviceName)
        deviceDatas = dashboard.devices.getDeviceDatas(devicesTable, deviceId)
        self.assertTrue(
            tools.waitUntil(lambda: dashboard.devices.getDeviceName(
                devicesTable, deviceId) == deviceName))
        self.assertEqual(
            dashboard.devices.getAttachedPlugin(devicesTable, deviceId),
            attachedPluginInstance)
Exemple #18
0
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 test_autostartCheckbox(self):
        print('=== Autostart Checkbox test ===')
        print('ref Issues : #182')
        ruleNumber = 0

        print('  Verify initial state')
        rulesTable = dashboard.automation.waitRulesTableHasNRules(
            self.browser, 1)
        self.assertFalse(
            dashboard.automation.getRuleAutoStartState(rulesTable, ruleNumber))

        print('  Uncheck the box')
        dashboard.automation.getRuleAutoStart(rulesTable, ruleNumber).click()
        tools.waitUntil(lambda: dashboard.automation.getRuleAutoStartState(
            rulesTable, ruleNumber) is True)

        print('  Reload page and check box state')
        dashboard.openSummary(self.browser)
        dashboard.openAutomation(self.browser)
        rulesTable = dashboard.automation.waitRulesTableHasNRules(
            self.browser, 1)
        tools.waitUntil(lambda: dashboard.automation.getRuleAutoStartState(
            rulesTable, ruleNumber) is True)

        print('  Check the box')
        dashboard.automation.getRuleAutoStart(rulesTable, ruleNumber).click()
        tools.waitUntil(lambda: dashboard.automation.getRuleAutoStartState(
            rulesTable, ruleNumber) is False)

        print('  Reload page and check box state')
        dashboard.openAutomation(self.browser)
        tools.waitUntil(lambda: dashboard.automation.getRuleAutoStartState(
            rulesTable, ruleNumber) is False)
Exemple #20
0
 def initialConditionsForRemoveRunningRuleTest(self, rulesTable,
                                               ruleNumber):
     tools.waitUntil(lambda: dashboard.automation.getRuleStartStopButton(
         rulesTable, ruleNumber).is_enabled())
     dashboard.automation.getRuleStartStopButton(rulesTable,
                                                 ruleNumber).click()
     self.assertTrue(
         tools.waitUntil(
             lambda: dashboard.automation.getRuleStartStopButton(
                 rulesTable, ruleNumber).is_enabled()))
     self.assertTrue(
         tools.waitUntil(lambda: dashboard.automation.getRuleState(
             rulesTable, ruleNumber) is dashboard.automation.RuleState.
                         Running))
Exemple #21
0
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 test_removePlugin(self):
      print ('=== Remove plugin test ===')
      pluginNumber = 0

      pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins(self.browser, 1)
      self.assertTrue(tools.waitUntil(lambda: dashboard.plugins.getPluginRemoveButton(pluginsTable, pluginNumber).is_enabled()))
      removeButton = dashboard.plugins.getPluginRemoveButton(pluginsTable, pluginNumber)
   
      print ('Remove plugin')
      removeButton.click()
      confirmationModal = dashboard.plugins.waitRemovePluginConfirmationModal(self.browser)
      confirmationModal.ok()
      
      print ('Check table updated')
      self.assertTrue(tools.waitUntil(lambda: dashboard.plugins.getPluginNumberInTable(self.browser, pluginsTable) == 0, 5))
Exemple #23
0
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(pluginType).click()
   newPluginModal.clickAdd()

   setPluginConfigurationSequenceFct(pluginInstanceName)
Exemple #24
0
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)
Exemple #25
0
def waitForClosed(modalWebElement):
   def l(modalWebElement):
      try:
         return 'display: none;' in modalWebElement.get_attribute('style')
      except Condition.StaleElementReferenceException:
         return True
   assert tools.waitUntil(lambda: l(modalWebElement))
Exemple #26
0
   def test_dontConfirmRemoveRule(self):
      print '=== Don\'t confirm remove rule test ==='

      # Wait startup notifications are closed
      self.assertTrue(tools.waitUntil(lambda: notification.noNotification(self.browser)))

      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)
      
      self.assertEqual(dashboard.automation.getRuleState(rulesTable, ruleNumber), dashboard.automation.RuleState.Stopped)
      
      print '  Remove rule'
      removeButton.click()
      confirmationModal = dashboard.automation.waitRemoveRuleConfirmationModal(self.browser)
      print '  Cancel'
      confirmationModal.cancel()
      
      print '  Expect no notification'
      self.assertTrue(notification.noNotification(self.browser))
      print '  Expect no change in rule table'
      self.assertEqual(dashboard.automation.getRuleNumberInTable(self.browser, rulesTable), 1)
Exemple #27
0
    def test_confirmRemoveDevice(self):
        print '=== Remove device ==='
        deviceName = u'fakeDimmableReadOnlySwitch'
        attachedPluginInstance = u'My fakePlugin instance'

        print '  Remove the device'
        devicesTable = dashboard.devices.waitDevicesTable(self.browser)
        devicesOriginalCount = dashboard.devices.countDevices(devicesTable)
        deviceId = dashboard.devices.waitDevicesTableHasDeviceNamed(
            self.browser, deviceName)
        dashboard.devices.getRemoveDeviceButton(devicesTable, deviceId).click()

        print '  Confirm removing'
        confirmRemoveModal = dashboard.devices.waitRemoveDeviceConfirmationModal(
            self.browser)
        confirmRemoveModal.ok()

        print '  Check that device was removed from list'
        devicesTable = dashboard.devices.waitDevicesTable(self.browser)
        assert tools.waitUntil(lambda: dashboard.devices.countDevices(
            devicesTable) == (devicesOriginalCount - 1))
        time.sleep(1)
        assert dashboard.devices.countDevices(devicesTable) == (
            devicesOriginalCount - 1)
        assert dashboard.devices.findDeviceInTable(devicesTable,
                                                   deviceName) is None
Exemple #28
0
    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))
Exemple #29
0
    def test_dontConfirmRemoveRule(self):
        print('=== Don\'t confirm remove rule test ===')

        # Wait startup notifications are closed
        self.assertTrue(
            tools.waitUntil(lambda: notification.noNotification(self.browser)))

        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)

        self.assertEqual(
            dashboard.automation.getRuleState(rulesTable, ruleNumber),
            dashboard.automation.RuleState.Stopped)

        print('  Remove rule')
        removeButton.click()
        confirmationModal = modals.waitOkCancelModal(self.browser)
        print('  Cancel')
        confirmationModal.cancel()

        print('  Expect no notification')
        self.assertTrue(notification.noNotification(self.browser))
        print('  Expect no change in rule table')
        self.assertEqual(
            dashboard.automation.getRuleNumberInTable(self.browser,
                                                      rulesTable), 1)
Exemple #30
0
    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)
Exemple #31
0
    def test_rightPagesDisplayed(self):
        print '=== Test navigation accros dashboard pages ==='
        print 'ref Issues : #172, #174'

        expectedPageTitles = [ \
           u'dashboard-summary', \
           u'dashboard-system-configuration', \
           u'dashboard-plugins', \
           u'dashboard-devices', \
           u'dashboard-automation-center', \
           u'dashboard-recipients', \
           u'dashboard-install-update', \
           u'dashboard-maintenance', \
           u'dashboard-about']

        expectedButtons = [ \
           u'btn-dashboard-summary', \
           u'btn-dashboard-system-configuration', \
           u'btn-dashboard-plugins', \
           u'btn-dashboard-devices', \
           u'btn-dashboard-automatisation', \
           u'btn-dashboard-recipients', \
           u'btn-dashboard-install-update', \
           u'btn-dashboard-maintenance', \
           u'btn-dashboard-about']

        print '  Enter dashboard'
        db = dashboard.open(self.browser)

        dashboardSubWindow = db.find_element_by_xpath(
            ".//div[@id='main-dashboard-sub-window-content']")
        dashboardButtons = db.find_element_by_xpath(
            ".//ul[@id='dashboard-btns']")
        menuEntries = dashboardButtons.find_elements_by_xpath("./child::*")
        self.assertEqual(len(menuEntries), len(expectedPageTitles))

        print '   Display all dashboard pages sequentially'

        def checkPage(dashboardSubWindow, expectedPageTitles, pageIndex):
            page = dashboardSubWindow.find_element_by_xpath(
                ".//div[@id='" + expectedPageTitles[pageIndex] + "']")
            self.assertTrue(tools.waitUntil(lambda: page.is_displayed()))

        def checkActiveButton(dashboardButtons, expectedButtons, pageIndex):
            activeButtons = dashboardButtons.find_elements_by_xpath(
                ".//li[@class='active']")
            if len(activeButtons) != 1:
                return False
            if activeButtons[0].get_attribute(
                    "id") != expectedButtons[pageIndex]:
                return False
            return True

        for page in range(0, len(menuEntries)):
            self.click(menuEntries, page)
            checkPage(dashboardSubWindow, expectedPageTitles, page)
            self.assertTrue(
                tools.waitUntil(lambda: checkActiveButton(
                    dashboardButtons, expectedButtons, page)))
Exemple #32
0
 def checkCreateWidget(self, widgetType, widgetTitle,
                       widgetExpectedPosition, widgetExpectedSize):
     print('  Check no notification occurs')
     self.assertTrue(notification.noNotification(self.browser))
     print('  Check widget present on main page')
     self.assertTrue(
         tools.waitUntil(lambda: mainPage.findWidgetOnCurrentPage(
             self.browser, widgetType, widgetTitle) is not None))
    def test_renameVirtualDevice(self):
        print('=== Rename a virtual device ===')
        deviceName = u'My virtual device'
        newDeviceName = u'myNewName'
        attachedPluginInstance = u'My fakePlugin instance'

        print('  Open the configure device modal')
        devicesTable = dashboard.devices.waitDevicesTable(self.browser)
        deviceId = dashboard.devices.waitDevicesTableHasDeviceNamed(
            self.browser, deviceName)
        dashboard.devices.getConfigureDeviceButton(devicesTable,
                                                   deviceId).click()
        configureVirtualDeviceModal = dashboard.devices.waitConfigureVirtualDeviceModal(
            self.browser)

        print('  Change virtual device name then cancel')
        configureVirtualDeviceModal.updateTextField('friendlyName',
                                                    newDeviceName)
        configureVirtualDeviceModal.cancel()
        self.assertTrue(
            tools.waitUntil(lambda: dashboard.devices.getDeviceName(
                devicesTable, deviceId) == deviceName))

        print('  Change virtual device name then confirm')
        dashboard.devices.getConfigureDeviceButton(devicesTable,
                                                   deviceId).click()
        configureVirtualDeviceModal = dashboard.devices.waitConfigureVirtualDeviceModal(
            self.browser)
        configureVirtualDeviceModal.updateTextField('friendlyName',
                                                    newDeviceName)
        configureVirtualDeviceModal.ok()
        self.assertTrue(
            tools.waitUntil(lambda: dashboard.devices.getDeviceName(
                devicesTable, deviceId) == newDeviceName))

        print('  Check change was saved')
        deviceId = dashboard.devices.waitDevicesTableHasDeviceNamed(
            self.browser, newDeviceName)
        dashboard.devices.getConfigureDeviceButton(devicesTable,
                                                   deviceId).click()
        configureVirtualDeviceModal = dashboard.devices.waitConfigureVirtualDeviceModal(
            self.browser)
        self.assertEqual(configureVirtualDeviceModal.getTextField('Name'),
                         newDeviceName)
        configureVirtualDeviceModal.cancel()
Exemple #34
0
    def test_driveOnOffKeyword(self):
        print('=== Try to drive a on/off keyword ===')
        print('ref Issues : #162')

        deviceName = u'fakeOnOffReadWriteSwitch'
        keywordName = u'Switch'

        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 True')
        button.click()
        setKeywordValueModal = dashboard.devices.waitSetValueKeywordModal(
            self.browser)
        assert setKeywordValueModal.getBoolValue() == False
        setKeywordValueModal.setBoolValue(True)
        setKeywordValueModal.ok()
        assert tools.waitUntil(
            lambda: dashboard.devices.getKeywordBoolValue(keyword) == True)

        print('  Set value to False')
        button.click()
        setKeywordValueModal = dashboard.devices.waitSetValueKeywordModal(
            self.browser)
        assert setKeywordValueModal.getBoolValue() == True
        setKeywordValueModal.setBoolValue(False)
        setKeywordValueModal.ok()
        assert tools.waitUntil(
            lambda: dashboard.devices.getKeywordBoolValue(keyword) == False)
Exemple #35
0
   def test_notDrivableKeyword(self):
      print '=== Check that a not drivable keyword doesnt have the drive button ==='
      deviceName = u'fakeOnOffReadOnlySwitch'
      keywordName = u'Switch'
      attachedPluginInstance = u'My fakePlugin instance'
     
      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 None
Exemple #36
0
   def test_removePlugin(self):
      print '=== Remove plugin test ==='
      pluginNumber = 0

      pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins(self.browser, 1)
      self.assertTrue(tools.waitUntil(lambda: dashboard.plugins.getPluginRemoveButton(pluginsTable, pluginNumber).is_enabled()))
      removeButton = dashboard.plugins.getPluginRemoveButton(pluginsTable, pluginNumber)
      
      # TODO nettoyer
      if not tools.waitUntil(lambda: dashboard.plugins.getPluginState(pluginsTable, pluginNumber) is dashboard.plugins.PluginState.Running):
         saveContext(self.browser)
         self.assertTrue(False)
   
      print 'Remove plugin'
      removeButton.click()
      confirmationModal = dashboard.plugins.waitRemovePluginConfirmationModal(self.browser)
      confirmationModal.ok()
      
      print 'Check table updated'
      self.assertTrue(tools.waitUntil(lambda: dashboard.plugins.getPluginNumberInTable(self.browser, pluginsTable) == 0, 5))
Exemple #37
0
 def test_configurePlugin(self):
    print '=== Configure plugin test ==='
    pluginNumber = 0
   
    print '  Configure the first plugin'
    pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins(self.browser, 1)
    tools.waitUntil(lambda: dashboard.plugins.getPluginConfigureButton(pluginsTable, pluginNumber).is_enabled())
    dashboard.plugins.getPluginConfigureButton(pluginsTable, pluginNumber).click()
    
    print '  Modify plugin name'
    pluginNewName = "This is the new plugin name"
    configurePluginModal = dashboard.plugins.waitConfigurePluginModal(self.browser)
    configurePluginModal.setPluginName(pluginNewName)
    configurePluginModal.ok()
    
    print '  Check modified plugin'
    pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins(self.browser, 1)
    pluginDatas = dashboard.plugins.getPluginDatas(pluginsTable, pluginNumber)
    self.assertTrue(tools.waitUntil(lambda: dashboard.plugins.getPluginName(pluginsTable, pluginNumber) == pluginNewName))
    self.assertEqual(dashboard.plugins.getPluginState(pluginsTable, pluginNumber), dashboard.plugins.PluginState.Running)
    self.assertTrue(dashboard.plugins.getPluginAutoStart(pluginsTable, pluginNumber))
Exemple #38
0
   def test_startStopPlugin(self):
      print '=== Start/stop plugin test ==='

      print 'Open plugins dashboard'
      dashboard.open(self.browser)
      dashboard.openPlugin(self.browser)
      pluginNumber = 0
      
      print 'Get plugins table'
      pluginsTable = dashboard.plugins.waitPluginsTableHasNPlugins(self.browser, 1)
      startStopButton = dashboard.plugins.getPluginStartStopButton(pluginsTable, pluginNumber)
      
      self.assertEqual(dashboard.plugins.getPluginState(pluginsTable, pluginNumber), dashboard.plugins.PluginState.Running)

      print 'Stop plugin'
      self.assertTrue(tools.waitUntil(lambda: startStopButton.is_enabled()))
      startStopButton.click()
      self.assertTrue(tools.waitUntil(lambda: dashboard.plugins.getPluginState(pluginsTable, pluginNumber) is dashboard.plugins.PluginState.Stopped))

      print 'Start plugin'
      self.assertTrue(tools.waitUntil(lambda: startStopButton.is_enabled()))
      startStopButton.click()
      self.assertTrue(tools.waitUntil(lambda: dashboard.plugins.getPluginState(pluginsTable, pluginNumber) is dashboard.plugins.PluginState.Running))
Exemple #39
0
   def test_driveEnumKeyword(self):
      print '=== Try to drive an enum keyword ==='
      print 'ref Issues : #176'

      deviceName = u'fakeController1'
      keywordName = u'controllerValue'
      attachedPluginInstance = u'My fakePlugin instance'
     
      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)
      setKeywordValueModal.setEnumValue('Run')
      setKeywordValueModal.ok()
      assert tools.waitUntil(lambda: dashboard.devices.getKeywordTextValue(keyword) == 'Run')

      print '  Set value to Left'
      button.click()
      setKeywordValueModal = dashboard.devices.waitSetValueKeywordModal(self.browser)
      setKeywordValueModal.setEnumValue('Left')
      setKeywordValueModal.ok()
      assert tools.waitUntil(lambda: dashboard.devices.getKeywordTextValue(keyword) == 'Left')
Exemple #40
0
 def test_createDevice(self):
    print '=== Manually device creation test ==='
    deviceName = u'My device'
    attachedPluginInstance = u'My fakePlugin instance'
   
    print '  Create the device'
    tools.waitUntil(lambda: dashboard.devices.getCreateDeviceButton(self.browser).is_enabled())
    dashboard.devices.getCreateDeviceButton(self.browser).click()
    newDeviceModal = dashboard.devices.waitNewDeviceModal(self.browser)
    newDeviceModal.selectAttachedPlugin(attachedPluginInstance).click()
    newDeviceModal.ok()
    
    print '  Configure the device'
    editDeviceModal = dashboard.devices.waitConfigureDeviceModal(self.browser)
    editDeviceModal.setDeviceName(deviceName)
    print '  Click OK'
    editDeviceModal.ok()
    
    print '  Check created device'
    devicesTable = dashboard.devices.waitDevicesTable(self.browser)
    deviceId = dashboard.devices.waitDevicesTableHasDeviceNamed(self.browser, deviceName)
    deviceDatas = dashboard.devices.getDeviceDatas(devicesTable, deviceId)
    self.assertTrue(tools.waitUntil(lambda: dashboard.devices.getDeviceName(devicesTable, deviceId) == deviceName))
    self.assertEqual(dashboard.devices.getAttachedPlugin(devicesTable, deviceId), attachedPluginInstance)
Exemple #41
0
   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))
Exemple #42
0
def waitForClosed(modalWebElement):
   assert tools.waitUntil(lambda: 'display: none;' in modalWebElement.get_attribute('style'))
Exemple #43
0
def waitForOpened(modalWebElement):
   assert tools.waitUntil(lambda: 'display: block;' in modalWebElement.get_attribute('style'))
Exemple #44
0
def waitPluginsTableHasNPlugins(browser, pluginsNumberExpected):
   pluginsTable = waitPluginsTable(browser)
   assert tools.waitUntil(lambda: getPluginNumberInTable(browser, pluginsTable) == pluginsNumberExpected)
   return pluginsTable
Exemple #45
0
 def initialConditionsForRemoveRunningRuleTest(self, rulesTable, ruleNumber):
    tools.waitUntil(lambda: dashboard.automation.getRuleStartStopButton(rulesTable, ruleNumber).is_enabled())
    dashboard.automation.getRuleStartStopButton(rulesTable, ruleNumber).click()
    self.assertTrue(tools.waitUntil(lambda: dashboard.automation.getRuleStartStopButton(rulesTable, ruleNumber).is_enabled()))
    self.assertTrue(tools.waitUntil(lambda: dashboard.automation.getRuleState(rulesTable, ruleNumber) is dashboard.automation.RuleState.Running))
Exemple #46
0
def waitSubText(browser, expectedType, expectedSubText):
   """ Wait for a notification containing expected text"""
   assert tools.waitUntil(lambda: isNotificationContainingText(browser, expectedType, expectedSubText))
Exemple #47
0
def waitText(browser, expectedType, expectedText):
   """ Wait for an expected notification """
   assert tools.waitUntil(lambda: isNotificationWithText(browser, expectedType, expectedText))
Exemple #48
0
def wait(browser, expectedType):
   """ Wait for an expected notification """
   assert tools.waitUntil(lambda: isNotification(browser, expectedType))
Exemple #49
0
def exitCustomizingMode(browser):
   if isCustomizing(browser):
      getCustomizeButton(browser).click()
      assert tools.waitUntil(lambda: not isCustomizing(browser))
Exemple #50
0
def waitDevicesTableHasDeviceNamed(browser, expectedDeviceName):
   devicesTable = waitDevicesTable(browser)
   assert tools.waitUntil(lambda: findDeviceInTable(devicesTable, expectedDeviceName) is not None)
   return findDeviceInTable(devicesTable, expectedDeviceName)