Example #1
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()
Example #2
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)
Example #3
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())
Example #4
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))
Example #5
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)
Example #6
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)
Example #7
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))
Example #8
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)
Example #9
0
    def setUp(self):
        database.deploy('OneFakePlugin')
        config.deploy("withDeveloperMode")
        self.serverProcess = yadomsServer.start()
        self.browser = webdriver.Firefox()
        self.browser.implicitly_wait(10)
        yadomsServer.openClient(self.browser)

        # Open plugins dashboard
        dashboard.open(self.browser)
        dashboard.openPlugin(self.browser)
Example #10
0
 def setUp(self):
    database.deploy('OneFakePlugin')
    config.deploy("withDeveloperMode")
    self.serverProcess = yadomsServer.start()
    self.browser = webdriver.Firefox()
    self.browser.implicitly_wait(10)
    yadomsServer.openClient(self.browser)
    
    # Open plugins dashboard
    dashboard.open(self.browser)
    dashboard.openPlugin(self.browser)
Example #11
0
 def setUp(self):
    database.deploy('OneStoppedRule')
    config.deploy("nominal")
    scripts.deploy(["DisplayServerVersion"])
    self.serverProcess = yadomsServer.start()
    self.browser = webdriver.Firefox()
    self.browser.implicitly_wait(10)
    yadomsServer.openClient(self.browser)
    
    # Open rules dashboard
    dashboard.open(self.browser)
    dashboard.openAutomation(self.browser)
    def setUp(self):
        yadomsServer.ensureStopped()
        database.deploy('OneStoppedRule')
        config.deploy("nominal")
        self.serverProcess = yadomsServer.start()
        self.browser = webdriver.Chrome()
        self.browser.implicitly_wait(10)
        yadomsServer.openClient(self.browser)

        # Open rules dashboard
        dashboard.open(self.browser)
        dashboard.openAutomation(self.browser)
Example #13
0
 def setUp(self):
    yadomsServer.ensureStopped()
    database.deploy('OneFakePlugin')
    config.deploy("withDeveloperMode")
    self.serverProcess = yadomsServer.start()
    self.browser = webdriver.Chrome()
    self.browser.implicitly_wait(10)
    yadomsServer.openClient(self.browser)
    
    # Open plugins dashboard
    dashboard.open(self.browser)
    dashboard.openDevice(self.browser)
    def setUp(self):
        yadomsServer.ensureStopped()
        database.deploy('OneVirtualDeviceApparentPower')
        config.deploy("withDeveloperMode")
        self.serverProcess = yadomsServer.start()
        self.browser = webdriver.Chrome(
            options=tools.ChromeOptionsHelper.get())
        self.browser.implicitly_wait(10)
        yadomsServer.openClient(self.browser)

        # Open plugins dashboard
        dashboard.open(self.browser)
        dashboard.openDevice(self.browser)
Example #15
0
    def setUp(self):
        yadomsServer.ensureStopped()
        database.deploy('OneStoppedRule')
        config.deploy("nominal")
        scripts.deploy(["DisplayServerVersion"])
        self.serverProcess = yadomsServer.start()
        self.browser = webdriver.Chrome(
            options=tools.ChromeOptionsHelper.get())
        self.browser.implicitly_wait(10)
        yadomsServer.openClient(self.browser)

        # Open rules dashboard
        dashboard.open(self.browser)
        dashboard.openAutomation(self.browser)
Example #16
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)
Example #17
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)
Example #18
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)))
Example #19
0
   def test_checkEntries(self):
      print '=== Main dashboard menu test ==='

      self.assertIn("Yadoms", self.browser.title)
      
      print '  Enter dashboard'
      dashboard.open(self.browser)
   
      print '  Check summary page'
      dashboard_boutons = self.browser.find_element_by_id("dashboard-btns")
      menuEntries = dashboard_boutons.find_elements_by_xpath("./child::*")
      self.assertEqual(len(menuEntries), 9)
      self.checkMenuEntry(menuEntries[0], "btn-dashboard-summary")
      self.checkMenuEntry(menuEntries[1], "btn-dashboard-system-configuration")
      self.checkMenuEntry(menuEntries[2], "btn-dashboard-plugins")
      self.checkMenuEntry(menuEntries[3], "btn-dashboard-devices")
      self.checkMenuEntry(menuEntries[4], "btn-dashboard-automatisation")
      self.checkMenuEntry(menuEntries[5], "btn-dashboard-recipients")
      self.checkMenuEntry(menuEntries[6], "btn-dashboard-install-update")
      self.checkMenuEntry(menuEntries[7], "btn-dashboard-maintenance")
      self.checkMenuEntry(menuEntries[8], "btn-dashboard-about")
Example #20
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))
Example #21
0
    def test_checkEntries(self):
        print('=== Main dashboard menu test ===')

        self.assertIn("Yadoms", self.browser.title)

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

        print('  Check summary page')
        dashboard_boutons = self.browser.find_element_by_id("dashboard-btns")
        menuEntries = dashboard_boutons.find_elements_by_xpath("./child::*")
        self.assertEqual(len(menuEntries), 9)
        self.checkMenuEntry(menuEntries[0], "btn-dashboard-summary")
        self.checkMenuEntry(menuEntries[1],
                            "btn-dashboard-system-configuration")
        self.checkMenuEntry(menuEntries[2], "btn-dashboard-plugins")
        self.checkMenuEntry(menuEntries[3], "btn-dashboard-devices")
        self.checkMenuEntry(menuEntries[4], "btn-dashboard-automatisation")
        self.checkMenuEntry(menuEntries[5], "btn-dashboard-recipients")
        self.checkMenuEntry(menuEntries[6], "btn-dashboard-install-update")
        self.checkMenuEntry(menuEntries[7], "btn-dashboard-maintenance")
        self.checkMenuEntry(menuEntries[8], "btn-dashboard-about")
Example #22
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))
   def test_quickNavigation(self):
      print '=== Test quick navigation accros dashboard pages ==='
      print 'ref Issues : #172'

      print '  Enter dashboard'
      db = dashboard.open(self.browser)
   
      dashboard_boutons = db.find_element_by_id("dashboard-btns")
      menuEntries = dashboard_boutons.find_elements_by_xpath("./child::*")

      for page in range(0, len(menuEntries)):
         self.click(menuEntries, page)

      nbDisplayedPages = len(self.getDisplayedPages(db.find_element_by_id("main-dashboard-sub-window-content")))
      if nbDisplayedPages != 1:
         print '   [FAIL] ' + str(nbDisplayedPages) + ' pages displayed, expected 1'
         assert False
    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']

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

        dashboard_boutons = db.find_element_by_id("dashboard-btns")
        menuEntries = dashboard_boutons.find_elements_by_xpath("./child::*")
        assert len(menuEntries) == len(expectedPageTitles)

        print '   Display all dashboard pages sequentially'

        # Note that the navigation is not perfect, but considered as acceptable for actual Yadoms version
        # See https://github.com/Yadoms/yadoms/issues/172 for more information

        def checkPage(dashboardSubWindow, expectedPageTitles, pageIndex):
            displayedPages = self.getDisplayedPages(dashboardSubWindow)
            assert len(displayedPages) == 1
            pageTitle = displayedPages[0].get_attribute('id')
            if pageTitle == expectedPageTitles[pageIndex]:
                print '   [OK] Get expected page (' + expectedPageTitles[
                    pageIndex] + ')'
                return True
            print '    [WARNING] Displayed page is ' + pageTitle + ', should be ' + expectedPageTitles[
                pageIndex]
            return False

        dashboardSubWindow = db.find_element_by_id(
            "main-dashboard-sub-window-content")
        for page in range(0, len(menuEntries)):
            assert tools.doUntil(
                lambda: self.click(menuEntries, page), lambda: checkPage(
                    dashboardSubWindow, expectedPageTitles, page), 3)
Example #25
0
    def test_quickNavigation(self):
        print '=== Test quick navigation accross dashboard pages ==='
        print 'At test end, only one page must be displayed'
        print 'ref Issues : #172'

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

        dashboardButtons = db.find_element_by_id("dashboard-btns")
        menuEntries = dashboardButtons.find_elements_by_xpath("./child::*")

        # Do several tests because #172 is not systematic
        for testId in range(0, 10):

            for page in range(0, len(menuEntries)):
                self.click(menuEntries, page)

            self.assertTrue(
                tools.waitUntil(lambda: len(
                    db.find_elements_by_xpath(
                        ".//div[@id='main-dashboard-sub-window-content']/div"))
                                == 1))