def testSetIssueUrl(self):
     """test the issue url is set."""
     issueUrl = 'http://www.example.com'
     name = "this is the test name"
     t = Test(name)
     # do test
     t.setIssueUrl(issueUrl)
     self.assertEqual(t.issueUrl, issueUrl)
 def testSetCleanup(self):
     """test the cleanup function is set."""
     def testFunction1():
         pass
     name = "this is the test name"
     t = Test(name)
     # do test
     t.setCleanup(testFunction1)
     self.assertEqual(t.cleanup, testFunction1)
 def testInit(self):
     """check if __init__ is correctly executed."""
     name = "this is the test name"
     t = Test(name)
     self.assertEqual(len(t.steps), 0)
     self.assertEqual(t.name, name)
     self.assertEqual(t.group, '')
     self.assertIn('<function <lambda> at ', str(t.cleanup))
     self.assertIsNone(t.cleanup())
     self.assertIsNone(t.issueUrl)
 def _test(n):
     test = Test("Verify '%s' tutorial" % n)
     test.addStep("Setting up project", lambda: loadTestProject(n))
     test.addStep("Creating web app", lambda: _createWebApp(n))
     test.addStep("Verify web app in browser", prestep=lambda: webbrowser.open_new(
                 "file:///" + webAppFolder.replace("\\","/") + "/webapp/index_debug.html"))
     return test
def functionalTests():
    test = Test('Functional test')
    test.addStep('Step 1',
                 prestep=lambda: True, isVerifyStep=True)
    test.addStep('Step 1',
                 prestep=lambda: True, isVerifyStep=True)
    test.setIssueUrl("http://www.example.com")
    return [test]
    def testAddStep(self):
        """check if a test is correclty added."""
        def testFunction1():
            pass

        def testFunction2():
            pass

        description1 = "this is a step description"
        description2 = "this is a step description"
        preStep = Step(description1, testFunction1)
        t = Test('this is the test name')
        # do test
        t.addStep(description2, testFunction2, preStep, True)
        self.assertEqual(len(t.steps), 1)
        s = t.steps[0]
        self.assertTrue(s.description == description2)
        self.assertTrue(s.function == testFunction2)
        self.assertTrue(s.prestep == preStep)
        self.assertTrue(s.isVerifyStep)
 def __init__(self, name, category = "General"):
     Test.__init__(self, name, category)
     self.addStep("Preparing test", backupConfiguration)
     self.setCleanup(restoreConfiguration)
Example #8
0
def functionalTests():
    spatialiteTest = Test("Test Spatialite. QGIS-72")
    spatialiteTest.addStep("Load Spatialite layer", _loadSpatialite)
    spatialiteTest.addStep("Open DB Manager", _openDBManager)
    spatialiteTest.addStep("Check that 'elk' layer is available in DB manager")

    aboutTest = Test("Verify dependency versions and providers in About dialog. QGIS-53")
    aboutTest.addStep("Open About dialog", _openAboutDialog)
    if sys.platform == 'darwin':
        descriptionFile = os.path.join(os.path.dirname(__file__), "data", "about.mac")
    else:
        descriptionFile = os.path.join(os.path.dirname(__file__), "data", "about.windows")
    aboutTest.addStep(descriptionFile)

    logTest = Test("Verify in-app message log has no errors for default install. QGIS-54")
    logTest.addStep("Open log messages panel", _openLogMessagesDialog)
    logTest.addStep("Review 'General' tab output", isVerifyStep = True)
    logTest.addStep("Check there are no errors in 'Plugins' tab", isVerifyStep = True)
    logTest.addStep("Check there is no 'Python warning' tab", isVerifyStep = True)
    logTest.addStep("Check there is no 'Qt' tab", isVerifyStep = True)
    logTest.addStep("Check there is no other tab", isVerifyStep = True)

    return [spatialiteTest, aboutTest, logTest]
    def testTest(self):
        ''' check test method:
        1) test if messageBox.warning is called
        2) open test selector widget
            2.1) cancel => do nothing
            2.2) ok =>
                2.2.1) Create TesterWidget and dock it
                2.2.2) load atests in it
                2.2.3) start running test
        '''
        # test 1)
        # preconditions
        qwidget = mock.Mock(spec=QWidget)
        qwidget.isVisible.return_value = True
        testerPlugin = TesterPlugin(self.IFACE_Mock)
        testerPlugin.widget = qwidget
        # do test1
        # I only test that PyQt4.QtGui.QMessageBox.warning is called in
        # the above preconditions
        qmessageboxMock = mock.Mock(spec=QMessageBox.warning)
        if isPyQt4:
            with mock.patch('PyQt4.QtGui.QMessageBox.warning', qmessageboxMock):
                testerPlugin.test()
            self.assertEqual("Tester plugin", str(qmessageboxMock.call_args[0][1]))
            self.assertEqual("A test cycle is currently being run", str(qmessageboxMock.call_args[0][2]))
        else:
            with mock.patch('PyQt5.QtWidgets.QMessageBox.warning', qmessageboxMock):
                testerPlugin.test()
            self.assertEqual("Tester plugin", str(qmessageboxMock.call_args[0][1]))
            self.assertEqual("A test cycle is currently being run", str(qmessageboxMock.call_args[0][2]))

        # test 2.1)
        # preconditions: TestSelector constructor mock return a mock simulating
        # a QDialog
        dlgMock = mock.Mock()
        dlgMock.tests = None
        testselectorMock = mock.Mock(spec=qgistester.testselector.TestSelector,
                                     return_value=dlgMock)
        testerPlugin = TesterPlugin(self.IFACE_Mock)
        testerPlugin.widget = None  # necessary to overpass first tested if
        # do test
        with mock.patch('qgistester.plugin.TestSelector', testselectorMock):
            testerPlugin.test()
        self.assertIsNone(testerPlugin.widget)

        # test 2.2 and 2.3
        # preconditions: TestSelector constructor mock return a mock simulating
        # a QDialog
        self.IFACE_Mock.reset_mock
        testselectorMock.reset_mock
        dlgMock.reset_mock
        mytest = Test("some tests")
        mytest.settings = {}
        dlgMock.tests = [mytest]
        testerwidgetMock = mock.Mock(spec=qgistester.testerwidget.TesterWidget,
                                     return_value=dlgMock)
        testerPlugin = TesterPlugin(self.IFACE_Mock)
        testerPlugin.widget = None  # necessary to overpass first tested if
        # do test
        with mock.patch('qgistester.plugin.TestSelector', testselectorMock):
            with mock.patch('qgistester.plugin.TesterWidget',
                            testerwidgetMock):
                testerPlugin.test()
        self.assertIsNotNone(testerPlugin.widget)
        self.assertIn('call.addDockWidget',
                      str(testerPlugin.iface.mock_calls[-1]))
        expected = [call.exec_(), call.exec_(), call.testingFinished.connect(testerPlugin.testingFinished),
                    call.show(), call.setTests([mytest]), call.startTesting()]
        self.assertEqual(dlgMock.mock_calls, expected)
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    tests = []
    test = Test("Create new repository")
    test.addStep("Set repos folder", lambda: _setReposFolder("new"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Create new repo and verify it is correctly added to the list")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Add layer without repo")
    test.addStep("Set repos folder", lambda: _setReposFolder("new"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Open test data", lambda: openTestProject("points"))
    test.addStep("Right click on the layer and try to add it to a repository.\n"
                 "Verify that it shows a warning because there are no repositories defined.")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Create new repository with existing name")
    test.addStep("Set repos folder", lambda: _setReposFolder("emptyrepo"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Create new repo named 'testrepo' and verify it cannot be created")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Change repository title")
    test.addStep("Set repos folder", lambda: _setReposFolder("emptyrepo"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Edit repository title and check it is updated in the repo summary")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Delete repository")
    test.addStep("Set repos folder", lambda: _setReposFolder("emptyrepo"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Delete repository and check it is removed from the list")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Add layer to repository")
    test.addStep("Set repos folder", lambda: _setReposFolder("emptyrepo"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Open test data", lambda: openTestProject("points"))
    test.addStep("Add layer 'points' to the 'testrepo' repository")
    test.addStep("Check layer has been added to repo", _checkLayerInRepo)
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Add layer with unconfigured user")
    test.addStep("Set repos folder", lambda: _setReposFolder("emptyrepo"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Open test data", lambda: openTestProject("points"))
    test.addStep("Remove user configuration", _removeUserConfig)
    test.addStep("Add layer 'points' to the 'testrepo' repository")
    test.addStep("Check layer has been added to repo", _checkLayerInRepo)
    test.setCleanup(_restoreUserConfig)
    tests.append(test)

    test = Test("Open repository layers in QGIS")
    test.addStep("Set repos folder", lambda: _setReposFolder("pointsrepo"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("New project", qgis.utils.iface.newProject)
    test.addStep("Select the 'testrepo' repository and click on 'Open repository in QGIS'")
    test.addStep("Check layer has been added to project", _checkLayerInProject)
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Update repository when there are no changes")
    test.addStep("New project", qgis.utils.iface.newProject)
    test.addStep("Set repos folder", lambda: _setReposFolder("pointsrepo"))
    test.addStep("Export repo layers", lambda:_exportRepoLayers("repo"))
    test.addStep("Right click on 'points' layer and select 'GeoGig/Update repository with this version'\n"
                 "Verify that the plugin shows that there are no changes to add")
    test.setCleanup(_cleanRepoClone)
    tests.append(test)

    test = Test("Modify feature and create new version")
    test.addStep("New project", qgis.utils.iface.newProject)
    test.addStep("Set repos folder", lambda: _setReposFolder("pointsrepo"))
    test.addStep("Export repo layers", lambda:_exportRepoLayers("repo"))
    test.addStep("Edit layer", _modifyFeature)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Update repository with this version'")
    test.addStep("Check layer has been updated", _checkFeatureModifiedInRepo)
    test.setCleanup(_cleanRepoClone)
    tests.append(test)

    test = Test("Add feature and create new version")
    test.addStep("New project", qgis.utils.iface.newProject)
    test.addStep("Set repos folder", lambda: _setReposFolder("pointsrepo"))
    test.addStep("Export repo layers", lambda:_exportRepoLayers("repo"))
    test.addStep("Edit layer", _addFeature)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Update repository with this version'")
    test.addStep("Check layer has been updated", _checkFeatureAddedInRepo)
    test.setCleanup(_cleanRepoClone)
    tests.append(test)

    test = Test("Add layer to repository from context menu")
    test.addStep("Open test data", lambda: openTestProject("points"))
    test.addStep("Set repos folder", lambda: _setReposFolder("emptyrepo"))
    test.addStep("Add layer using context menu")
    test.addStep("Check layer has been added to repo", _checkLayerInRepo)
    test.addStep("Check layer context menus", _checkLayerHasTrackedContextMenus)
    test.setCleanup(_cleanRepoClone)
    tests.append(test)

    test = Test("Remove layer from repository")
    test.addStep("New project", qgis.utils.iface.newProject)
    test.addStep("Set repos folder", lambda: _setReposFolder("pointsrepo"))
    test.addStep("Export repo layers", lambda:_exportRepoLayers("repo"))
    test.addStep("Right click on 'points' layer and select 'GeoGig/Remove layer from repository'")
    test.addStep("Check layer has been correctly deleted", _checkLayerNotInRepo)
    test.addStep("Check layer context menus", _checkLayerHasUntrackedContextMenus)
    test.setCleanup(_cleanRepoClone)
    tests.append(test)

    test = Test("Show version characteristics")
    test.addStep("Set repos folder", lambda: _setReposFolder("pointsrepo"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Right click on repo's only commit and select 'Show detailed description'\nVerify description is correctly shown")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Create new branch")
    test.addStep("Set repos folder", lambda: _setReposFolder("pointsrepo"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Create new branch at current branch's HEAD and verify it is added to history tree")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Switch branch")
    test.addStep("Set repos folder", lambda: _setReposFolder("twobranches"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("New project", qgis.utils.iface.newProject)
    test.addStep("Export repo layers", lambda:_exportRepoLayers("repo"))
    test.addStep("Switch to 'newbranch' branch and verify the map is updated")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Merge branch")
    test.addStep("Set repos folder", lambda: _setReposFolder("twobranches"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("New project", qgis.utils.iface.newProject)
    test.addStep("Export repo layers", lambda:_exportRepoLayers("repo"))
    test.addStep("Merge 'newbranch' into 'master' and verify the map and versions tree are updated")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Merge conflicted  branch")
    test.addStep("Set repos folder", lambda: _setReposFolder("conflicted"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("New project", qgis.utils.iface.newProject)
    test.addStep("Export repo layers", lambda:_exportRepoLayers("repo"))
    test.addStep("Merge 'conflicted' into 'master' and solve the conflicts.\n"
                 "Verify the merge is correctly finished and the tree and map are updated")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Merge conflicted  branch and abort")
    test.addStep("Set repos folder", lambda: _setReposFolder("conflicted"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("New project", qgis.utils.iface.newProject)
    test.addStep("Export repo layers", lambda:_exportRepoLayers("repo"))
    test.addStep("Merge 'conflicted' into 'master' and abort.\n"
                 "Verify the merge is correctly aborted.")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Delete branch")
    test.addStep("Set repos folder", lambda: _setReposFolder("twobranches"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Delete 'newbranch' and verify the versions tree is updated")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Pull from remote")
    test.addStep("Set repos folder", lambda: _setReposFolder("remote"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Add remote", _addRemote)
    test.addStep("New project", qgis.utils.iface.newProject)
    test.addStep("Export repo layers", lambda:_exportRepoLayers("local"))
    test.addStep("Sync local repo pulling from remote.\n"
                 "Verify the repo and the map are correctly updated.")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    test = Test("Pull from remote with conflicts")
    test.addStep("Set repos folder", lambda: _setReposFolder("conflictedremote"))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Add remote", _addRemote)
    test.addStep("New project", qgis.utils.iface.newProject)
    test.addStep("Sync local repo pulling from remote.\n"
                 "Verify the conflict is detected.")
    test.setCleanup(_removeTempRepoFolder)
    tests.append(test)

    return tests
def functionalTests():
    ''' functional tests. e.g. intergration test or all tests that require user interacion '''
    try:
        from qgistester.test import Test
    except:
        return []
    
    _tests = []
    
    function1Test = Test("Function 1 description")
    function1Test.addStep("do preparation step 1", function1Step1)
    function1Test.addStep("Message to user to do some action => press 'next step'")
    function1Test.addStep("do previous step check", function1Step2)
    function1Test.setCleanup(cleanUpFunction1)
    _tests.append(function1Test)
    
    function2Test = Test("Function 2 description")
    function2Test.addStep("do preparation step 1", function2Step1)
    function2Test.addStep("Message to user to do some action => press 'next step'")
    function2Test.addStep("do previous step check", function2Step2)
    function2Test.setCleanup(cleanUpFunction2)
    _tests.append(function2Test)

    return _tests
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    userProfileAutosaveTest = Test("""Check that user profile is saved on first execution""")
    userProfileAutosaveTest.addStep("Rename user profile folder", _deleteUserProfiles)
    userProfileAutosaveTest.addStep("Select any profile in the profiles menu")
    userProfileAutosaveTest.addStep("Check file was created", _checkFileCreated)
    userProfileAutosaveTest.setCleanup(_recoverUserProfiles)

    userProfileAutosaveFromManagerTest = Test("""Check that user profile is saved on first execution from Profiles Manager""")
    userProfileAutosaveFromManagerTest.addStep("Rename user profile folder", _deleteUserProfiles)
    userProfileAutosaveFromManagerTest.addStep("Select any profile and set it. "
                                               "Check that a new entry appears under the 'user profiles' group",
                                               prestep = _openProfileManager, isVerifyStep = True)
    userProfileAutosaveFromManagerTest.addStep("Check file was created", _checkFileCreated)
    userProfileAutosaveFromManagerTest.setCleanup(lambda: _runFunctions([_closeProfileManager, _recoverUserProfiles]))

    noMenusTest = Test("""Check that a profile with no buttons is correctly applied""")
    noMenusTest.addStep("Save previous state", _savePreviousState)
    noMenusTest.addStep("Apply profile", lambda: applyProfile("nobuttons.json"))
    noMenusTest.addStep("Verify no toolbar is visible")
    noMenusTest.setCleanup(_recoverPreviousState)

    noMenusFromManagerTest = Test("""Check that a profile is correctly applied from the Plugin Manager""")
    noMenusFromManagerTest.addStep("Save previous state", _savePreviousState)
    noMenusFromManagerTest.addStep("Open profile manager", lambda: _openProfileManager)
    noMenusFromManagerTest.addStep("Set the 'no buttons' profile. Verify it has been applied and no toolbar is visible", isVerifyStep=True)
    noMenusFromManagerTest.setCleanup(_recoverPreviousState)

    cannotInstallPlugin = Test("""Check that when a plugin cannot be installed, a warning is shown""")
    cannotInstallPlugin.addStep("Save previous state", _savePreviousState)
    cannotInstallPlugin.addStep("Apply profile", lambda: applyProfile("wrongplugin.json"))
    cannotInstallPlugin.addStep("Verify warning is displayed: 'profile applied with errors'")
    cannotInstallPlugin.setCleanup(_recoverPreviousState)

    correctlySetPanelsTest = Test("""Check that panels are correctly set by profile""")
    correctlySetPanelsTest.addStep("Save previous state", _savePreviousState)
    correctlySetPanelsTest.addStep("Apply profile", lambda: applyProfile("onlyonepanel.json"))
    correctlySetPanelsTest.addStep("Verify log panel is the only visible panel")
    correctlySetPanelsTest.setCleanup(_recoverPreviousState)

    correctlySetPythonConsoleTest = Test("""Check that Python console is correctly handled""")
    correctlySetPythonConsoleTest.addStep("Save previous state", _savePreviousState)
    correctlySetPythonConsoleTest.addStep("Apply profile", lambda: applyProfile("pythonconsole.json"))
    correctlySetPythonConsoleTest.addStep("Verify Python console is visible")
    correctlySetPythonConsoleTest.setCleanup(_recoverPreviousState)

    renameMenuTest = Test("""Check that menu rename is correctly performed""")
    renameMenuTest.addStep("Save previous state", _savePreviousState)
    renameMenuTest.addStep("Apply profile", lambda: applyProfile("renamemenu.json"))
    renameMenuTest.addStep("Verify Processing Toolbox menu entry has been renamed")
    renameMenuTest.setCleanup(_recoverPreviousState)

    customButtonsTest = Test("""Check that custom toolbars are correctly created""")
    customButtonsTest.addStep("Save previous state", _savePreviousState)
    customButtonsTest.addStep("Apply profile", lambda: applyProfile("onlynavigationtoolbar.json"))
    customButtonsTest.addStep("Verify map navigation toolbar is the only one visible, and is splitted into two toolbars",
                              isVerifyStep = True)
    customButtonsTest.addStep("Recover previous state", _recoverPreviousState)
    customButtonsTest.addStep("Verify navigation toolbar is not split anymore")

    def _enableProcessing():
        loadPlugin("processing")
        startPlugin("processing")
        QtCore.QSettings().setValue('/PythonPlugins/processing', True)
        updateAvailablePlugins()
        updatePluginManager()
        assert "processing" in active_plugins

    processingIgnoredTest = Test("""Check Processing is ignored""")
    processingIgnoredTest.addStep("Enable Processing", _enableProcessing)
    processingIgnoredTest.addStep("Save previous state", _savePreviousState)
    processingIgnoredTest.addStep("Apply profile", lambda: applyProfile("noplugins.json"))
    processingIgnoredTest.addStep("Verify Processing menu is available")
    processingIgnoredTest.setCleanup(_recoverPreviousState)

    profilesPluginIgnoredTest = Test("""Check Profiles entries are ignored when setting up menus""")
    profilesPluginIgnoredTest.addStep("Save previous state", _savePreviousState)
    profilesPluginIgnoredTest.addStep("Apply profile", lambda: applyProfile("nomenus.json"))
    profilesPluginIgnoredTest.addStep("Verify Settings/Profiles menus are available")
    profilesPluginIgnoredTest.setCleanup(_recoverPreviousState)

    def _removeTestPlugin():
        unloadPlugin("what3words")
        updateAvailablePlugins()
        updatePluginManager()
        assert "what3words" not in available_plugins

    def _checkTestPlugin():
        assert "what3words" in active_plugins

    correctlyDownloadPluginTest = Test("""Check plugin is correctly downloaded and installed""")
    correctlyDownloadPluginTest.addStep("Save previous state", _savePreviousState)
    correctlyDownloadPluginTest.addStep("Manually remove what3words if installed")#TODO:automate this
    correctlyDownloadPluginTest.addStep("Apply profile", lambda: applyProfile("onlyoneplugin.json"))
    correctlyDownloadPluginTest.addStep("Verify plugin is installed", _checkTestPlugin)
    correctlyDownloadPluginTest.addStep("Verify Plugins/what3words plugin menu is available")
    correctlyDownloadPluginTest.setCleanup(_recoverPreviousState)

    folder = os.path.join(os.path.dirname(os.path.dirname(__file__)), "userprofiles")
    profilesCount = len([name for name in os.listdir(folder) if name.endswith(".json")])
    setMenuEntriesTest = Test("""Check that menu entries are correctly created""")
    setMenuEntriesTest.addStep("Verify settings/profiles menu has %i available profiles" % profilesCount)

    noEmptyMenusTest = Test("""Check that no empty menus are shown""")
    noEmptyMenusTest.addStep("Save previous state", _savePreviousState)
    noEmptyMenusTest.addStep("Apply profile", lambda: applyProfile("noemptymenus.json"))
    noEmptyMenusTest.addStep("Verify that the 'Layers/New Layer' menu does not exist")
    noEmptyMenusTest.setCleanup(_recoverPreviousState)

    createCustomProfileTest = Test("""Check that the current state is correctly saved in manager""")
    createCustomProfileTest.addStep("Rename user profile folder", _deleteUserProfiles)
    createCustomProfileTest.addStep("Create a new profile with the current configuration and check that the profile appears in the profiles tree",
                                                prestep = _openProfileManager, isVerifyStep = True)
    createCustomProfileTest.addStep("Click on the profile. In the description panel, click on 'delete profile' and check that the profile is deleted",
                                                prestep = _openProfileManager, isVerifyStep = True)
    createCustomProfileTest.setCleanup(lambda: _runFunctions([_closeProfileManager, _recoverUserProfiles]))

    expandBoxesInToolBarTest = Test("""Check boxes are expanded in toolbars""")
    expandBoxesInToolBarTest.addStep("Save previous state", _savePreviousState)
    expandBoxesInToolBarTest.addStep("Apply profile", lambda: applyProfile("decision_maker.json"))
    expandBoxesInToolBarTest.addStep("Verify search box in toolbar has a normal size (not too small)")
    expandBoxesInToolBarTest.setCleanup(_recoverPreviousState)

    customLayersTest = Test("""Check that custom layers are kept on profiles changing""")
    customLayersTest.addStep("Save previous state", _savePreviousState)
    customLayersTest.addStep("Apply profile", lambda: applyProfile("data_manager.json"))
    customLayersTest.addStep("Add raster layer using QuickMapServices plugin", isVerifyStep=False)
    customLayersTest.addStep("Apply profile", lambda: applyProfile("decision_maker.json"))
    customLayersTest.addStep("Verify that raster layer still loaded in project")
    customLayersTest.setCleanup(_recoverPreviousState)


    return [userProfileAutosaveTest, userProfileAutosaveFromManagerTest,
            noMenusTest, noMenusFromManagerTest, cannotInstallPlugin,
            correctlySetPanelsTest, renameMenuTest, customButtonsTest,
            processingIgnoredTest, profilesPluginIgnoredTest,
            correctlyDownloadPluginTest, setMenuEntriesTest, noEmptyMenusTest,
            createCustomProfileTest, correctlySetPythonConsoleTest,
            expandBoxesInToolBarTest, customLayersTest
            ]
def functionalTests():
    try:
        from qgistester.test import Test
        from qgistester.utils import loadLayer
        import mgrs
    except:
        return []

    def _loadLayer():
        layerfile = os.path.join(os.path.dirname(__file__), "data", "MGRS_100kmSQ_ID_02H.shp")
        layer = loadLayer(layerfile)
        QgsMapLayerRegistry.instance().addMapLayer(layer)

    def _setTool():
        plugins["mgrstools"].setTool()

    def _zoomTo():
        plugins["mgrstools"].zoomTo()

    mgrsTest = Test("Test MRGS tools")
    mgrsTest.addStep("Load layer", _loadLayer)
    mgrsTest.addStep("Select map tool", _setTool)
    mgrsTest.addStep("Click within the upper left polygon. Verify that the computed mrgrs coord starts with 02HKK'", isVerifyStep = True)
    mgrsTest.addStep("Open panel", _zoomTo)
    mgrsTest.addStep("Enter '02HKK' and click on 'zoom to'. Verify it centers the view on to the upper left polygon and adds a marker")
    mgrsTest.addStep("Click on 'remove marker' and verify it removes the marker")
    return [mgrsTest]
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    emptyCredentialsTest = Test('Check Connect plugin recognize empty credentials')
    emptyCredentialsTest.addStep('Press "Login" button without entering any credentials. '
                                 'Check that Connect shows error message complaining about empty credentials.'
                                 'Close error message by pressing "Ok" button.'
                                 'Check that the Connect panel shows login page.',
                                 prestep=lambda: _startConectPlugin(),
                                 isVerifyStep=True)

    invalidCredentialsTest = Test('Check Connect plugin recognize invalid credentials')
    invalidCredentialsTest.addStep('Enter invalid Connect credentials and accept dialog by pressing "Login" button. '
                                   'Check that dialog asking for credentials is shown and close it by pressing "Cancel" button. '
                                   'Check that Connect shows error message complaining about invalid credentials. '
                                   'Close error message by pressing "Ok" button. '
                                   'Check that the Connect panel shows login page.',
                                   prestep=lambda: _startConectPlugin(),
                                   isVerifyStep=True)

    invalidEndpointTest = Test('Check login with wrong endpoint')
    invalidEndpointTest.addStep('Open plugin settings from "PLugins -> Boundless Connect -> Plugin Settings" menu. '
                                'Enter "https://dummy.com" as Connect endpoint and close dialog by pressing OK.')
    invalidEndpointTest.addStep('Enter valid Connect credentials and press "Login" button. Verify that error '
                                'message about token is shown and login page is active.',
                                prestep=lambda: _startConectPlugin(),
                                isVerifyStep=True)

    repeatedLoginTest = Test("Check repeated logging")
    repeatedLoginTest.addStep('Enter valid Connect credentials, check "Remember me" '
                              'checkbox and press "Login" button.',
                              prestep=lambda: _startConectPlugin())
    repeatedLoginTest.addStep('Check that label with your login info '
                              'is shown in the lower part of the Connect panel.',
                              isVerifyStep=True)
    repeatedLoginTest.addStep('Click on the "Logout" button')
    repeatedLoginTest.addStep('Verify that login and password fields are '
                              'filled with login and password you used at '
                              'the previous login and "Remember me" checkbox '
                              'is checked.',
                              isVerifyStep=True)
    repeatedLoginTest.addStep('Enter another another valid credentials and '
                              'keep "Remember me" checkbox checked. Press '
                              '"Login" button.',
                              isVerifyStep=True)
    repeatedLoginTest.addStep('Check that in the lower part of Connect '
                              'plugin, correct login name is displayed.',
                              isVerifyStep=True)
    repeatedLoginTest.addStep('Click on the "Logout" button')
    repeatedLoginTest.addStep('Verify that login and password fields are '
                              'filled with login and password you used at '
                              'the previous login and "Remember me" checkbox '
                              'is checked.',
                              isVerifyStep=True)
    repeatedLoginTest.addStep('Close Connect dock.')
    repeatedLoginTest.addStep('Open Connect dock from "Plugins -> Boundless Connect" '
                              'menu. Verify that login and password fields are '
                              'filled with login and password you used at '
                              'the previous login',
                              isVerifyStep=True)
    repeatedLoginTest.addStep('Uncheck "Remember me". Close Connect dock.',)
    repeatedLoginTest.addStep('Open Connect dock from "Plugins -> Boundless Connect" '
                              'menu. Verify that login and password fields are '
                              'empty and "Remember me" checkbox is unchecked.',
                              isVerifyStep=True)

    emptySearchTest = Test("Check empty search")
    emptySearchTest.addStep('Enter valid Connect credentials and press "Login" button.',
                            prestep=lambda: _startConectPlugin())
    emptySearchTest.addStep('Verify that "Knowledge" tab is shown, '
                            'populated with content and no error is thrown',
                            isVerifyStep=True)
    emptySearchTest.addStep('Switch to the "Data" tab. Verify that '
                            'some results are shown and no error is thrown',
                            isVerifyStep=True)
    emptySearchTest.addStep('Switch to the "Plugins" tab. Verify that '
                            'some results are shown and no error is thrown',
                            isVerifyStep=True)
    emptySearchTest.addStep('Type "mapbox" in the search box and Switch '
                            'to the "Knowledge" tab. Verify that some '
                            'results are shown and no error is thrown',
                            isVerifyStep=True)
    emptySearchTest.addStep('Switch to the "Plugins" tab. Verify that no '
                            'results are shown and no error is thrown',
                            isVerifyStep=True)
    emptySearchTest.addStep('Clear search field and switch to the "Data" '
                            'tab. Verify that some results are shown and '
                            'no error is thrown',
                            isVerifyStep=True)

    searchTest = Test("Check normal search")
    searchTest.addStep('Enter valid Connect credentials and press "Login" button.',
                       prestep=lambda: _startConectPlugin())
    searchTest.addStep('Verify that "Knowledge" tab is shown, '
                       'populated with content and no error is thrown',
                       isVerifyStep=True)
    searchTest.addStep('Type "gdal" in the search box and press Enter. '
                       'Verify that a list of results is shown.',
                       isVerifyStep=True)
    searchTest.addStep('Type "lesson" in the search box and switch '
                       'to the "Plugins" tab. Verify that one plugin result is shown.',
                       isVerifyStep=True)
    searchTest.addStep('Type "mapbox" in the search box and switch '
                       'to the "Data" tab. Verify that a list of results is shown.',
                       isVerifyStep=True)

    paginationTest = Test("Check normal search")
    paginationTest.addStep('Enter valid Connect credentials and press "Login" button.',
                           prestep=lambda: _startConectPlugin())
    paginationTest.addStep('Verify that "Knowledge" tab is shown, '
                           'populated with content and no error is thrown',
                           isVerifyStep=True)
    paginationTest.addStep('Type "geogig" in the search box and press Enter. '
                           'Verify that a list of results is shown and there is'
                           'a "Next" button at the bottom',
                           isVerifyStep=True)
    paginationTest.addStep('Click on the "Next" button. Verify that new '
                           'results are loaded and at the bottom there are '
                           'two buttons: "Next" and "Previous"',
                           isVerifyStep=True)
    paginationTest.addStep('Continue clicking on the "Next" button until '
                           'last page loaded. Verify that only "Previous" '
                           'is shown at the bottom of the results list',
                            isVerifyStep=True)
    paginationTest.addStep('Click on the "Previous" button. Verify that '
                           'new you returned to the previous page.',
                           isVerifyStep=True)
    paginationTest.addStep('Continue clicking on the "Previous" button until '
                           'first page loaded. Verify that only "Next" '
                           'is shown at the bottom of the results list',
                            isVerifyStep=True)

    wrongSearchTest = Test("Check wrong search")
    wrongSearchTest.addStep('Enter valid Connect credentials and press "Login" button.',
                            prestep=lambda: _startConectPlugin())
    wrongSearchTest.addStep('Verify that "Knowledge" tab is shown, '
                            'populated with content and no error is thrown',
                            isVerifyStep=True)
    wrongSearchTest.addStep('Type "wrongsearch" in the search box and '
                            'press Enter. Verify that a warning is displayed.',
                            isVerifyStep=True)

    categorySearchTest = Test("Check search by categories")
    categorySearchTest.addStep('Enter valid Connect credentials and press "Login" button.',
                               prestep=lambda: _startConectPlugin())
    categorySearchTest.addStep('Verify that "Knowledge" tab is shown, '
                               'populated with content and no error is thrown',
                               isVerifyStep=True)
    categorySearchTest.addStep('Type "MIL-STD-2525" in the search box and '
                               'ensure no category is selected in "Search in" '
                               'combobox. Press Enter. Verify that multiple '
                               'results are shown and they are from '
                               'different categories.',
                               isVerifyStep=True)
    categorySearchTest.addStep('Type "style" in the search box and in '
                               'the "Search in" combobox select "Lesson" '
                               'and deselect any other items. '
                               'Click on the "Search" button again and '
                               'check that only lessons results are shown',
                               isVerifyStep=True)
    categorySearchTest.addStep('In the "Search in" combobox additionaly '
                               'select "Learning". Click on the "Search" '
                               'button again and check that multiple results '
                               'are shown: lesson and learning center content.',
                               isVerifyStep=True)

    pluginSearchTest = Test("Check that plugins search results correctly retrieved")
    pluginSearchTest.addStep('Login with valid Connect credentials',
                             prestep=lambda: _startConectPlugin())
    pluginSearchTest.addStep('Verify that "Knowledge" tab is shown, '
                             'populated with content and no error is thrown',
                             isVerifyStep=True)
    pluginSearchTest.addStep('Switch to the "Plugins" tab, type '
                             '"MIL-STD-2525" in the search field '
                             'and press search button')
    pluginSearchTest.addStep('Verify that single plugin result returned.',
                             isVerifyStep=True)

    rolesDisplayTest = Test("Check roles display")
    rolesDisplayTest.addStep('Enter valid (non-enterprise) Connect credentials and press "Login" button.',
                             prestep=lambda: _startConectPlugin())
    rolesDisplayTest.addStep('Verify that "Knowledge" tab is shown, '
                             'populated with content and no error is thrown',
                             isVerifyStep=True)
    rolesDisplayTest.addStep('Switch to the "Plugin" tab. Type '
                             '"MIL-STD-2525" in the search box and '
                             'press Enter. Verify that one plugin result '
                             'is shown and is not available (orange)',
                             isVerifyStep=True)
    rolesDisplayTest.addStep('Click on "MIL-STD-2525" and verify it '
                             'opens a browser where the user can '
                             'subscribe to Boundless Connect',
                             isVerifyStep=True)
    rolesDisplayTest.addStep('Click on the "Logout" button')
    rolesDisplayTest.addStep('Login with credentials for "Desktop Enterprise"')
    rolesDisplayTest.addStep('Verify that "Knowledge" tab is shown, '
                             'populated with content and no error is thrown',
                             isVerifyStep=True)
    rolesDisplayTest.addStep('Switch to the "Plugin" tab. Type '
                             '"MIL-STD-2525" in the search box and '
                             'press Enter. Verify that one plugin result '
                             'is shown and is available (blue)',
                             isVerifyStep=True)
    rolesDisplayTest.addStep('Click on "MIL-STD-2525" and verify it '
                             'install the plugins or tells you that it '
                             'is already installed',
                             isVerifyStep=True)

    basemapsLoadingTest = Test("Check basemaps loading")
    basemapsLoadingTest.addStep('Login with credentials for "Desktop Enterprise".',
                                prestep=lambda: _startConectPlugin())
    basemapsLoadingTest.addStep('Verify that "Knowledge" tab is shown, '
                                'populated with content and no error is thrown',
                                isVerifyStep=True)
    basemapsLoadingTest.addStep('Type "mapbox" in the search box and '
                                'switch to the "Data" tab. Verify that '
                                'list of the basemaps shown.',
                                isVerifyStep=True)
    basemapsLoadingTest.addStep('Press "ADD TO MAP" button under any '
                                'basemap and verify that basemap added '
                                'to the current project and no error is thrown.',
                                isVerifyStep=True)
    basemapsLoadingTest.addStep('Pan canvas in different directions, '
                                'zoom in and out to ensure that basemap '
                                'is working correctly and no error is thrown.',
                                isVerifyStep=True)
    basemapsLoadingTest.addStep('Press "ADD TO MAP" button under another '
                                'basemap from the search results and '
                                'verify that second basemap added to '
                                'the current project and no error is thrown.',
                                isVerifyStep=True)
    basemapsLoadingTest.addStep('Pan canvas in different directions, '
                                'zoom in and out to ensure that basemap '
                                'is working correctly and no error is thrown.',
                                isVerifyStep=True)
    basemapsLoadingTest.addStep('Change visibility of both basemaps, '
                                'reorder them in the layer tree to '
                                'ensure that they are working correctly '
                                'and no error is thrown.',
                                isVerifyStep=True)

    defaultProjectTest = Test("Check simple default project")
    defaultProjectTest.addStep('Login with credentials for "Desktop Enterprise".',
                                prestep=lambda: _startConectPlugin())
    defaultProjectTest.addStep('Switch to the "Data" tab. Type "mapbox" '
                                'in the search box and press Enter. '
                                'Verify that list of the basemaps shown.',
                                isVerifyStep=True)
    defaultProjectTest.addStep('Press "ADD TO DEFAULT PROJECT" button '
                               'under any basemap and verify that '
                               'message saying it was added to the '
                               'default project shown and no error '
                               'is thrown.',
                                isVerifyStep=True)
    defaultProjectTest.addStep('Press "New project" button at the QGIS '
                               'toolbar and verify new project with '
                               'basemap added by default created.',
                                isVerifyStep=True)
    defaultProjectTest.addStep('Change visibility of basemap, zoom in '
                               'and out, pan acros the map to ensure '
                               'that it works correctly and no error '
                               'is thrown.',
                                isVerifyStep=True)
    defaultProjectTest.addStep('Unset default project',
                               function=lambda: basemaputils.unsetDefaultProject())

    complexDefaultProjectTest = Test("Check complex default project")
    complexDefaultProjectTest.addStep('Login with credentials for "Desktop Enterprise".',
                                      prestep=lambda: _startConectPlugin())
    complexDefaultProjectTest.addStep('Switch to the "Data" tab. Type "mapbox" '
                                      'in the search box and press Enter. '
                                      'Verify that list of the basemaps shown.',
                                      isVerifyStep=True)
    complexDefaultProjectTest.addStep('Press "ADD TO DEFAULT PROJECT" button '
                                      'under any basemap and verify that '
                                      'message saying it was added to the '
                                      'default project shown and no error '
                                      'is thrown.',
                                      isVerifyStep=True)
    complexDefaultProjectTest.addStep('Press "ADD TO DEFAULT PROJECT" button '
                                      'under another basemap and verify that '
                                      'message saying it was added to the '
                                      'default project shown and no error '
                                      'is thrown.',
                                      isVerifyStep=True)
    complexDefaultProjectTest.addStep('Press "New project" button at the QGIS '
                                      'toolbar and verify new project with '
                                      'two basemaps added by default created.',
                                      isVerifyStep=True)
    complexDefaultProjectTest.addStep('Change visibility of basemap, '
                                      'reorder them in layer tree, zoom in '
                                      'and out, pan acros the map to ensure '
                                      'that it works correctly and no error '
                                      'is thrown.',
                                      isVerifyStep=True)
    complexDefaultProjectTest.addStep('Unset default project',
                                      function=lambda: basemaputils.unsetDefaultProject())

    lessonsInstallTest = Test("Check lessons installation")
    lessonsInstallTest.addStep('Login with credentials for "Desktop Enterprise".',
                               prestep=lambda: _startConectPlugin())
    lessonsInstallTest.addStep('Switch to the "Plugins" tab. Type "lessons" '
                               'in the search box and press Enter. '
                               'Verify that single plugin result is '
                               'shown and available for installation '
                               '(button color is blue).',
                               isVerifyStep=True)
    lessonsInstallTest.addStep('Press "INSTALL" button and verify that '
                               'plugin installed, activated and no error '
                               'is thrown.',
                               isVerifyStep=True)
    lessonsInstallTest.addStep('Switch to the "Knowledge" tab, enter '
                               '"lesson" in the search box and select '
                               '"Lessons" from the "Search in" combobox. '
                               'Press Enter to perform search, verify '
                               'that lessons results are shown and no '
                               'available (buttons are blue) and no '
                               'error is thrown.',
                               isVerifyStep=True)
    lessonsInstallTest.addStep('Press "LESSON" button under any lesson '
                               'result and verify that lessons installed, '
                               'activated and no error is thrown.',
                               isVerifyStep=True)

    helpTest = Test("Check Help displaying")
    helpTest.addStep('Click on "Help" button and verify help is '
                     'correctly open in a browser.',
                     prestep=lambda: _startConectPlugin())

    toggleVisibilityTest = Test("Check visibility toggling")
    toggleVisibilityTest.addStep('Close Connect dock.',
                                 prestep=lambda: _startConectPlugin())
    toggleVisibilityTest.addStep('Open dock from menu "Plugins -> Boundless '
                                 'Connect". Verify that dock opened with '
                                 'active login screen.',
                                 isVerifyStep=True)
    toggleVisibilityTest.addStep('Close Connect dock.')
    toggleVisibilityTest.addStep('Right-click on QGIS toolbar and check '
                                 '"Boundless Connect" panel. Verify that '
                                 'dock opened with active login screen.',
                                 isVerifyStep=True)
    toggleVisibilityTest.addStep('Enter valid Connect credentials and press "Login" button and then '
                                 'close dock.')
    toggleVisibilityTest.addStep('Open dock from menu "Plugins -> Boundless '
                                 'Connect". Verify that dock opened with '
                                 'active search screen.',
                                 isVerifyStep=True)
    toggleVisibilityTest.addStep('Close dock.')
    toggleVisibilityTest.addStep('Right-click on QGIS toolbar and check '
                                '"Boundless Connect" panel. Verify that '
                                'dock opened with active search screen.',
                                 isVerifyStep=True)


    return [emptyCredentialsTest, invalidCredentialsTest, repeatedLoginTest,
            invalidEndpointTest, emptySearchTest, searchTest, paginationTest,
            wrongSearchTest, categorySearchTest, pluginSearchTest, rolesDisplayTest,
            basemapsLoadingTest, defaultProjectTest, complexDefaultProjectTest,
            lessonsInstallTest, helpTest, toggleVisibilityTest]
Example #15
0
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    passingTest = Test('This test should pass')
    passingTest.addStep('Click on "Test passes"')

    skippedTest = Test('This test should be skiped')
    skippedTest.addStep('Click on "Skip test"')

    def failingFunction():
        assert False
    failingTest = Test('This test should fail')
    failingTest.addStep("Failing step", function=failingFunction)

    failingSetupTest = Test('This test should fail in the step setup')
    failingSetupTest.addStep("Failing prestep", prestep=failingFunction)

    def errorFunction():
        raise Exception ("Error in test")
    errorTest = Test('This test should error')
    errorTest.addStep("Error step", function=errorFunction)

    return [passingTest, skippedTest, failingTest, failingSetupTest, errorTest]
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    dragdropTest = Test("Verify dragging browser element into workspace")
    # pki context setup
    dragdropTest.addStep("Setting up pki auth context", utils.initAuthManager)
    dragdropTest.addStep("configuring pki auth context", utils.populatePKITestCerts)
    # normal steps
    dragdropTest.addStep("Setting up catalog and explorer", utils.setUpCatalogAndExplorer)
    dragdropTest.addStep("Setting up test data project", utils.loadTestData)
    dragdropTest.addStep("Drag layer from browser 'Project home->qgis_plugin_test_pt1.shp' into\ntest_catalog->Workspaces->test_workspace")
    dragdropTest.addStep("Checking new layer", utils.checkNewLayer)
    # cleaup with clean of pki context
    dragdropTest.setCleanup(utils.cleanAndPki)

    vectorRenderingTest = Test("Verify rendering of uploaded style")
    # pki context setup
    vectorRenderingTest.addStep("Setting up pki auth context", utils.initAuthManager)
    vectorRenderingTest.addStep("configuring pki auth context", utils.populatePKITestCerts)
    # normal steps
    vectorRenderingTest.addStep("Preparing data", utils.openAndUpload)
    vectorRenderingTest.addStep("Check that WMS layer is correctly rendered")
    # cleaup with clean of pki context
    vectorRenderingTest.setCleanup(utils.cleanAndPki)

    return [dragdropTest, vectorRenderingTest]
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    logTest = Test("Verify in-app message log has no errors for default install. QGIS-62")
    logTest.addStep("Open log messages panel",
                    prestep=lambda:_openLogMessagesDialog())
    logTest.addStep("Review 'General' tab output. Check it has no issues",
                    isVerifyStep=True)
    logTest.addStep("Check there are no errors in 'Plugins' tab",
                    isVerifyStep=True)
    logTest.addStep("If exists, check there are no errors in 'Python warning' tab",
                    isVerifyStep=True)
    logTest.addStep("If exists, check there are no errors in 'Qt' tab",
                    isVerifyStep=True)
    logTest.addStep("Review the Init Script, check there are no errors in 'Qt' tab",
                    isVerifyStep=True)
    logTest.addStep("Review any other existing tabs, check that there are no errors",
                    isVerifyStep=True)

    spatialiteTest = Test("Test Spatialite. QGIS-120")
    spatialiteTest.addStep("Load Spatialite layer",
                           prestep=lambda:_loadSpatialite())
    spatialiteTest.addStep("Open DB Manager",
                           prestep=lambda:_openDBManager())
    spatialiteTest.addStep("Check that 'test' layer is available "
                           "in DB manager, in 'Virtual layers/QGIS layers'",
                           isVerifyStep=True)

    aboutTest = Test("Verify dependency versions and providers in About dialog. QGIS-53")
    aboutTest.addStep("Open About dialog",
                      prestep=lambda:_openAboutDialog())
    if sys.platform == 'darwin':
        filePath = os.path.join(testPath, "data", "about.mac")
    else:
        filePath = os.path.join(testPath, "data", "about.windows")
    with open(filePath) as f:
        content = f.readlines()
    data = ""
    for line in content:
        data += "<p>{}</p>".format(line)
    aboutTest.addStep("Verify that content of the About dialog matches"
                      "following data\n{}\n\n".format(data),
                      isVerifyStep=True)

    arcmapTest = Test("Test ArcMapserver")
    arcmapTest.addStep("Load layer",
                           prestep=_loadArcMap)

    arcfeatureTest = Test("Test ArcFeatureserver")
    arcfeatureTest.addStep("Load layer",
                           prestep=_loadArcFeature)

    wcsTest = Test("Test WCS")
    wcsTest.addStep("Load WCS layer",
                           prestep=_loadWcs)

    wfsTest = Test("Test WFS")
    wfsTest.addStep("Modify and load WFS layer",
                           prestep=_modifyAndLoadWfs)

    postgisTest = Test("Test PostGIS")
    postgisTest.addStep("Create and load PostGIS layer",
                           prestep=_addToDbAndLoadLayer)

    offlineTest = Test("WFS Smoke Test (Server) - Offline Editing")
    offlineTest.addStep("Load WFS layer layer",
                           prestep=_loadWfsToBeEdited)
    offlineTest.addStep("Enable *Offline editing* plugin from *Plugins > Manage and install plugins* in the *Installed* tab.",
                           isVerifyStep=True)
    offlineTest.addStep("Convert the project to an offline project by selecting *Database > Offline editing > Convert to offline project*. Keep the layer selected and click *OK*.",
                           isVerifyStep=True)
    offlineTest.addStep("Enable editing on the recently added layer. Activate the layer in the *Layers* panel and enable editing."
                        " In the *Digitizing toolbar* (in the second row of menu icons), click the *Toggle editing* icon (it's a pencil)"
                         "or from menus go to *Layer > Toogle Editing* This will allow you to edit the layer.",
                           isVerifyStep=True)
    offlineTest.addStep("Click the *Add Feature* icon in the same toolbar.",
                           isVerifyStep=True)
    offlineTest.addStep('''
Click once anywhere in the viewer window - this sets the first vertex of the polygon. Keep clicking other places to add more vertices.

*on OS X*:
to finish the polygon hold the control key down and click (this will add one last vertex).

*on Windows*:
use the right mouse button to end (no other vertex is added).

When you complete the polygon a *Feature Attributes* dialog will pop-up.

Simply click the *Ok* button to dismiss it.
''',
                           isVerifyStep=True)
    offlineTest.addStep("Click the *Save Layer Edits* icon or go to *Layer > Save Layer Edits* menu.",
                           isVerifyStep=True)
    offlineTest.addStep("Click the *Toggle Editing* icon or select the 'Toggle Editing' menu item under Layer.",
                           isVerifyStep=True)
    offlineTest.addStep("Sync the project by selecting *Database > Offline editing > Synchronize*",
                           isVerifyStep=True)    
    offlineTest.addStep("Verify that your changes were stored on the GeoServer. Compare the edited layer with the new one, and verify that they are identical.",
                           prestep= lambda: _loadWfsToBeEdited("testlayer_afterediting"), isVerifyStep=True)    

    return [spatialiteTest, logTest, aboutTest, wcsTest, wfsTest, arcmapTest, arcfeatureTest, postgisTest, offlineTest]
def functionalTests():
    try:
        from qgistester.test import Test
        from qgistester.utils import layerFromName
    except:
        return []


    def _openProject():
        projfile = os.path.join(os.path.dirname(__file__), "data", "project.qgs")
        iface.addProject(projfile)

    def _openLayerProperties():
        layer = layerFromName("2525")
        iface.showLayerProperties(layer)

    def _openAttributesTable():
        layer = layerFromName("2525")
        iface.showAttributeTable(layer)

    def _startEditing():
        layer = layerFromName("2525")
        layer.startEditing()

    def _stopEditing():
        layer = layerFromName("2525")
        layer.rollBack()
        iface.newProject()

    def _setRenderer():
        r = MilStd2525Renderer(40, "SDIC")
        layer = layerFromName("2525")
        layer.setRendererV2(r)
        layer.reload()
        layer.triggerRepaint()
        iface.mapCanvas().setExtent(layer.extent())

    def _changeSize():
        layer = layerFromName("2525")
        r = layer.rendererV2()
        r.size = 80
        layer.triggerRepaint()

    editWidgetTest = Test("Test code edit widget")
    editWidgetTest.addStep("Open project", _openProject)
    #editWidgetTest.addStep("Open layer properties", _openLayerProperties)
    editWidgetTest.addStep("Open layer properties, go to the 'Fields' tab  and set the edit widget of the SDIC field to 'SDIC code editor'")
    editWidgetTest.addStep("Toggle editing", _startEditing)
    editWidgetTest.addStep("Open attributes table", _openAttributesTable)
    editWidgetTest.addStep("Edit a value in the table using the code editor widget and check that it works correctly")
    editWidgetTest.addStep("Toggle editing", _stopEditing)

    rendererTest = Test("Renderer test")
    rendererTest.addStep("Open project", _openProject)
    rendererTest.addStep("Open layer properties. Go to the 'Style' tab and set renderer of the layer "
                         "to 'MIL-STD-2525' renderer. Close dialog by pressing 'OK' button", _openLayerProperties)
    rendererTest.addStep("Verify that layer rendered correctly.")

    sizeChangeTest = Test("Size change test")
    sizeChangeTest.addStep("Open project", _openProject)
    sizeChangeTest.addStep("Set renderer", _setRenderer)
    sizeChangeTest.addStep("Verify that the layer is rendered with MIL-STD-2525 symbology", isVerifyStep=True)
    sizeChangeTest.addStep("Change size", _changeSize)
    sizeChangeTest.addStep("Verify that the size of symbols has changed")

    return [editWidgetTest, rendererTest, sizeChangeTest]
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    dragdropTest = Test("Verify dragging browser element into workspace")
    dragdropTest.addStep("Setting up pki auth context", lambda: utils.setUtilContext(pki=True))
    dragdropTest.addStep("Setting up catalog and explorer", utils.setUpCatalogAndExplorer)
    dragdropTest.addStep("Setting up test data project", utils.loadTestData)
    dragdropTest.addStep("Drag layer from browser 'Project home->qgis_plugin_test_pt1.shp' into\ntest_catalog->Workspaces->test_workspace")
    dragdropTest.addStep("Checking new layer", utils.checkNewLayer)
    dragdropTest.setCleanup(utils.clean)

    vectorRenderingTest = Test("Verify rendering of uploaded style")
    vectorRenderingTest.addStep("Setting up basic pki context", lambda: utils.setUtilContext(pki=True))
    vectorRenderingTest.addStep("Preparing data", utils.openAndUpload)
    vectorRenderingTest.addStep("Check that WMS layer is correctly rendered")
    vectorRenderingTest.setCleanup(utils.clean)

    return [dragdropTest, vectorRenderingTest]
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    openPluginManagerTest = Test('Verify that Boundless Connect can start Plugin Manager')
    openPluginManagerTest.addStep('Check that OpenGeo Explorer listed in Plugin Manager as well as plugins from QGIS repository',
                                prestep=lambda: _openPluginManager(False), isVerifyStep=True)
    openPluginManagerTest.setIssueUrl("https://issues.boundlessgeo.com:8443/browse/QGIS-325")

    openPluginManagerBoundlessOnlyTest = Test('Verify that Boundless Connect can start Plugin Manager only with Boundless plugins')
    openPluginManagerBoundlessOnlyTest.addStep('Check that Plugin manager is open and contains only Boundless plugins',
                                prestep=lambda: _openPluginManager(True), isVerifyStep=True)
    openPluginManagerBoundlessOnlyTest.setIssueUrl("https://issues.boundlessgeo.com:8443/browse/QGIS-325")

    coreConnectUpdateTest = Test('Test updating core Connect plugin via Plugin Manager')
    coreConnectUpdateTest.addStep('Downgrade installed Connect plugin', lambda: _downgradePlugin('boundlessconnect'))
    coreConnectUpdateTest.addStep('Check that Connect plugin is upgradable',
                                  prestep=lambda: _openPluginManager(True), isVerifyStep=True)
    coreConnectUpdateTest.addStep('Upgrade Connect plugin')
    coreConnectUpdateTest.addStep('Check that Connect plugin updated, loaded from user folder and has latest version', isVerifyStep=True)
    coreConnectUpdateTest.setIssueUrl("https://issues.boundlessgeo.com:8443/browse/QGIS-602")
    coreConnectUpdateTest.setCleanup(lambda: _restoreVersion('boundlessconnect'))

    return [openPluginManagerTest, openPluginManagerBoundlessOnlyTest, coreConnectUpdateTest]
def functionalTests():
    try:
        from qgistester.test import Test
        from qgistester.utils import layerFromName
    except:
        return []

    dragdropTest = Test("Verify dragging browser element into workspace")
    dragdropTest.addStep("Setting up catalog and explorer", _setUpCatalogAndExplorer)
    dragdropTest.addStep("Drag layer from browser into testing workspace of testing catalog")
    dragdropTest.addStep("Checking new layer", _checkNewLayer)
    dragdropTest.setCleanup(_clean)

    vectorRenderingTest = Test("Verify rendering of uploaded style")
    vectorRenderingTest.addStep("Preparing data", _openAndUpload)
    vectorRenderingTest.addStep("Check that WMS layer is correctly rendered")
    vectorRenderingTest.setCleanup(_clean)

    return [dragdropTest, vectorRenderingTest]
def functionalTests():
    try:
        from qgistester.test import Test
        from qgistester.utils import layerFromName
    except:
        return []

    def _createWebApp(n):
        global webAppFolder
        webAppFolder = createAppFromTestAppdef(n)

    def _test(n):
        test = Test("Verify '%s' tutorial" % n)
        test.addStep("Setting up project", lambda: loadTestProject(n))
        test.addStep("Creating web app", lambda: _createWebApp(n))
        test.addStep("Verify web app in browser", prestep=lambda: webbrowser.open_new(
                    "file:///" + webAppFolder.replace("\\","/") + "/webapp/index_debug.html"))
        return test
    tests = [_test("bakeries"), _test("schools"), _test("fires")]

    unconfiguredBookmarksTest = Test("Verify bookmarks widget cannot be used if no bookmarks defined")
    unconfiguredBookmarksTest.addStep("Load project", lambda: loadTestProject())
    unconfiguredBookmarksTest.addStep("Open WAB", lambda: openWAB())
    unconfiguredBookmarksTest.addStep("Try to create an app with the bookmarks widget, without configuring it to add bookmarks.\n"
                         "Verify it shows a warning.")
    unconfiguredBookmarksTest.setCleanup(closeWAB)
    tests.append(unconfiguredBookmarksTest)

    unsupportedSymbologyTest = Test("Verify warning for unsupported symbology")
    unsupportedSymbologyTest.addStep("Load project", lambda: loadTestProject())
    unsupportedSymbologyTest.addStep("Open WAB", openWAB)
    unsupportedSymbologyTest.addStep("Click on 'Preview'. Verify a warning about unsupported symbology is shown.\n"
                         "Verify it shows a warning.")
    tests.append(unsupportedSymbologyTest)
    unsupportedSymbologyTest.setCleanup(closeWAB)

    wrongLogoTest = Test("Verify warning for wrong logo file")
    wrongLogoTest.addStep("Load project", lambda: loadTestProject())
    wrongLogoTest.addStep("Open WAB", openWAB)
    wrongLogoTest.addStep("Enter 'wrong' in the logo textbox and click on 'Preview'."
                                     "The logo texbox should get a yellow background.")
    wrongLogoTest.setCleanup(closeWAB)
    tests.append(wrongLogoTest)

    previewWithAllWidgetsTest = Test("Verify preview of an app with all widgets")
    previewWithAllWidgetsTest.addStep("Load project", lambda: loadTestProject("layers"))
    appdef = testAppdef("allwidgets", False)
    previewWithAllWidgetsTest.addStep("Open WAB", lambda: openWAB(appdef))
    previewWithAllWidgetsTest.addStep("Click on 'Preview' and verify app is correctly shown and it works.")
    previewWithAllWidgetsTest.setCleanup(closeWAB)
    tests.append(previewWithAllWidgetsTest)

    return tests