コード例 #1
0
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]
コード例 #2
0
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    allTests = []
    dragdropTest = Test("Verify dragging browser element into workspace")
    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)

    allTests.append(dragdropTest)

    for testProject in utils.testProjects():
        renderingTest = Test("Verify rendering of uploaded style (%s)" %
                             os.path.basename(testProject))
        renderingTest.addStep("Preparing data",
                              partial(utils.openAndUpload, testProject))
        renderingTest.addStep("Check that WMS layer is correctly rendered")
        renderingTest.setCleanup(utils.clean)
        allTests.append(renderingTest)

    return allTests
コード例 #3
0
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]
コード例 #4
0
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
コード例 #5
0
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]
コード例 #6
0
 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)
コード例 #7
0
    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)
コード例 #8
0
    def testSetCleanup(self):
        """Test if cleanup function is set"""
        def testFunction1():
            pass

        name = 'this is the test name'
        t = Test(name)

        t.setCleanup(testFunction1)
        self.assertEqual(t.cleanup, testFunction1)
コード例 #9
0
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]
コード例 #10
0
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
コード例 #11
0
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("Setting up test data project", _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", _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]
コード例 #12
0
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    dragdropTest = Test("Verify dragging browser element into workspace")
    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("Preparing data", utils.openAndUpload)
    vectorRenderingTest.addStep("Check that WMS layer is correctly rendered")
    vectorRenderingTest.setCleanup(utils.clean)

    return [dragdropTest, vectorRenderingTest]
コード例 #13
0
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
コード例 #14
0
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
            ]
コード例 #15
0
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 tests")
    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
コード例 #16
0
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")
        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
            ]
コード例 #17
0
def functionalTests():
    try:
        from qgistester.test import Test
        from qgistester.utils import layerFromName
    except:
        return []

    def _createWebApp(n, checkApp=False):
        global webAppFolder
        webAppFolder = createAppFromTestAppdef(n, checkApp)

    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)

    nodataTest = Test("Verify that NODATA values are transparent")
    nodataTest.addStep("Load project", lambda: loadTestProject("nodata"))
    nodataTest.addStep("Creating web app", lambda: _createWebApp("nodata"))
    nodataTest.addStep(
        "Verify web app in browser. NODATA values should be transparent. "
        "<b>NOTE</b> don't use Chrome/Chromium to check this web app they "
        "have bug and it might not work as expected. Use Firefox or another browser.",
        prestep=lambda: webbrowser.open_new("file:///" + webAppFolder.replace(
            "\\", "/") + "/webapp/index_debug.html"))
    tests.append(nodataTest)

    wmsTimeinfoTest = Test("Verify that spatio-temporal WMS layers supported")
    wmsTimeinfoTest.addStep("Load project",
                            lambda: loadTestProject("wms-timeinfo-interval"))
    wmsTimeinfoTest.addStep(
        "Creating web app",
        lambda: _createWebApp("wms-timeinfo-interval", True))
    wmsTimeinfoTest.addStep(
        "Verify web app in browser.",
        prestep=lambda: webbrowser.open_new("file:///" + webAppFolder.replace(
            "\\", "/") + "/webapp/index_debug.html"))
    tests.append(wmsTimeinfoTest)

    return tests
コード例 #18
0
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    # advanced setting editing are reset after closing of options gui - #26327
    testAdvancedSettings = Test('Advanced settings editor saves changes',
                                category='Regression tests')
    testAdvancedSettings.setIssueUrl(
        'https://github.com/qgis/QGIS/issues/26327')
    testAdvancedSettings.addStep(
        'Open QGIS Settings and change some values using Advanced Settings Editor and close dialog by pressing OK button.',
        prestep=lambda: _showOptions(),
        busyCursor=False)
    testAdvancedSettings.addStep(
        'Open QGIS Settings again. Check that previously changed settings have correct values.',
        prestep=lambda: _showOptions(),
        isVerifyStep=True,
        busyCursor=False)

    # adding WMTS from Browser paner - #36264
    testBrowserAddWmts = Test('Adding WMTS from Browser',
                              category='Regression tests')
    testBrowserAddWmts.setIssueUrl('https://github.com/qgis/QGIS/issues/36264')
    testBrowserAddWmts.addStep('Create test WMTS connection.',
                               function=lambda: _addWmtsConnection())
    testBrowserAddWmts.addStep(
        'Expand "WMS/WMTS" node in the Browser panel. Then expand "TesterPlugin" connection.'
    )
    testBrowserAddWmts.addStep(
        'Try to add layer "112 Par satellite" from the Browser to QGIS canvas. Check that QGIS prompts for date and after setting a date layer added to canvas and visible.',
        isVerifyStep=True)
    testBrowserAddWmts.setCleanup(lambda: _removeWmtsConnection())

    # adding rows in the Processing batch interface - #39696
    testAddBatchRows = Test('Adding new rows in Processing batch interface',
                            category='Regression tests')
    testAddBatchRows.setIssueUrl('https://github.com/qgis/QGIS/issues/39696')
    testAddBatchRows.addStep('Start native "Buffer" algorithm in batch mode',
                             prestep=lambda: _runProcessingBatch(),
                             busyCursor=False)
    testAddBatchRows.addStep(
        'Check that every time green plus button in the dialog toolbar is pressed a new row added to the batch.',
        isVerifyStep=True)
    testAddBatchRows.addStep('Close dialog by pressing "Close" button.')

    # filename prefix not shown when loading GPX or similar files - #37551
    testGpxFilenamePrefix = Test(
        'Filename prefix is not shown when adding layers from GPX',
        category='Regression tests')
    testGpxFilenamePrefix.setIssueUrl(
        'https://github.com/qgis/QGIS/issues/37551')
    testGpxFilenamePrefix.addStep(
        'Add GPX layer to QGIS. Ensure that all layers in the "Select Vector Layers to Add" dialog are selected and "Add layers to group" checkbox is checked. Press "OK" button',
        prestep=lambda: iface.addVectorLayer(
            os.path.join(dataPath, 'elev.gpx'), 'elev', 'ogr'),
        busyCursor=False)
    testGpxFilenamePrefix.addStep(
        'Check that in the layer tree there is an "elev" group with 5 layers inside it and layer names are not prefixed with the "elev".',
        isVerifyStep=True)
    testGpxFilenamePrefix.addStep(
        'Remove group with layers from the project.',
        function=lambda: QgsProject.instance().clear())
    testGpxFilenamePrefix.addStep(
        'Add GPX layer to QGIS. Ensure that all layers in the "Select Vector Layers to Add" dialog are selected and "Add layers to group" checkbox is NOT checked. Press "OK" button',
        prestep=lambda: iface.addVectorLayer(
            os.path.join(dataPath, 'elev.gpx'), 'elev', 'ogr'),
        busyCursor=False)
    testGpxFilenamePrefix.addStep(
        'Check that in the layer tree there are 5 layers and their layer names are prefixed with the "elev".',
        isVerifyStep=True)
    testGpxFilenamePrefix.setCleanup(lambda: QgsProject.instance().clear())

    # check Processing providers
    testProcessingProviders = Test('Processing providers are functional',
                                   category='Installation Smoke tests')
    testProcessingProviders.addStep(
        'Open Processing toolbox from the "Processing -> Toolbox" menu')
    testProcessingProviders.addStep(
        'Verify that native QGIS tools groups are exist in the Processing toolbox.',
        isVerifyStep=True)
    testProcessingProviders.addStep(
        'Verify that the GDAL group is exist in the Processing toolbox and that it contains several sub-groups.',
        isVerifyStep=True)
    testProcessingProviders.addStep(
        'Verify that the GRASS group is exist in the Processing toolbox and that it contains several sub-groups.',
        isVerifyStep=True)
    testProcessingProviders.addStep(
        'Verify that the SAGA group is exist in the Processing toolbox and that it contains several sub-groups.',
        isVerifyStep=True)

    return [
        testAdvancedSettings,
        testBrowserAddWmts,
        testAddBatchRows,
        testGpxFilenamePrefix,

        # generic tests not linked to any ticket
        testProcessingProviders
    ]
コード例 #19
0
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
コード例 #20
0
def functionalTests():
    # create TestCase instance to use Assert methods
    tc = unittest.TestCase('__init__')

    try:
        from qgistester.test import Test
        from qgistester.utils import layerFromName
    except:
        return []

    def _createWebApp(n, preview=True, aboutContent=None):
        global webAppFolder
        webAppFolder = createAppFromTestAppdef(n, preview, aboutContent)

    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")]

    appdefFolder = os.path.join(os.path.dirname(__file__), "data")

    def _testWidget(n):
        aboutContent = widgetTestAbout.get(n, None)
        test = Test("Verify '%s' widget" % n)
        test.addStep("Setting up project", lambda: loadTestProject("widgets"))
        test.addStep("Creating web app",
                     lambda: _createWebApp(n, True, aboutContent))
        test.addStep("Verify web app in browser",
                     prestep=lambda:
                     webbrowser.open_new("file:///" + webAppFolder.replace(
                         "\\", "/") + "/webapp/index_debug.html"))
        return test

    for w in widgets:
        for i in ["", "2", "3"]:
            testName = w + i
            f = os.path.join(appdefFolder, "%s.appdef" % testName)
            if os.path.exists(f):
                tests.append(_testWidget(testName))

    def _openComparison(n):
        webbrowser.open_new("file:///" +
                            os.path.dirname(__file__).replace("\\", "/") +
                            "/expected/apps/%s/index_debug.html" % n)
        webbrowser.open_new("file:///" + webAppFolder.replace("\\", "/") +
                            "/webapp/index_debug.html")

    def _comparisonTest(n):
        test = Test("Symbology test '%s'" % n)
        test.addStep("Setting up project", lambda: loadTestProject(n))
        test.addStep("Creating web app", lambda: _createWebApp(n))
        test.addStep("Compare web app with expected app in browser",
                     prestep=lambda: _openComparison(n))
        return test

    comparisonTests = [
        "points", "points2", "osm", "polygons", "labels", "arrows"
    ]
    for t in comparisonTests:
        tests.append(_comparisonTest(t))

    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."
    )
    unsupportedSymbologyTest.setCleanup(closeWAB)
    tests.append(unsupportedSymbologyTest)

    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)

    nodataTest = Test("Verify that NODATA values are transparent")
    nodataTest.addStep("Load project", lambda: loadTestProject("nodata"))
    nodataTest.addStep("Creating web app", lambda: _createWebApp("nodata"))
    nodataTest.addStep(
        "Verify web app in browser. NODATA values should be transparent. "
        "<b>NOTE</b> don't use Chrome/Chromium to check this web app they "
        "have bug and it might not work as expected. Use Firefox or another browser.",
        prestep=lambda: webbrowser.open_new("file:///" + webAppFolder.replace(
            "\\", "/") + "/webapp/index_debug.html"))
    tests.append(nodataTest)

    createEmpyAppTest = Test("Verify preview an app with no layers")
    createEmpyAppTest.addStep("Load project", iface.newProject)
    createEmpyAppTest.addStep("Open WAB", lambda: openWAB())
    createEmpyAppTest.addStep(
        "Create an app preview and check it is correctly created")
    createEmpyAppTest.setCleanup(closeWAB)
    tests.append(createEmpyAppTest)

    wrongEndpointTest = Test("Verify wrong SDK service URL")
    wrongEndpointTest.addStep("Load project", iface.newProject)
    wrongEndpointTest.addStep("Load project", _setWrongSdkEndpoint)
    wrongEndpointTest.addStep("Open WAB", lambda: openWAB())
    wrongEndpointTest.addStep(
        "Try to create an app and check it complains of a wrong URL")
    wrongEndpointTest.setCleanup(_resetSdkEndpoint)
    tests.append(wrongEndpointTest)

    wmsTimeinfoTest = Test("Verify that spatio-temporal WMS layers supported")
    wmsTimeinfoTest.addStep("Load project",
                            lambda: loadTestProject("wms-timeinfo-interval"))
    wmsTimeinfoTest.addStep(
        "Creating web app",
        lambda: _createWebApp("wms-timeinfo-interval", checkApp=True))
    wmsTimeinfoTest.addStep(
        "Verify web app in browser.",
        prestep=lambda: webbrowser.open_new("file:///" + webAppFolder.replace(
            "\\", "/") + "/webapp/index_debug.html"))
    tests.append(wmsTimeinfoTest)

    try:
        from boundlessconnect.tests.testerplugin import _startConectPlugin
        denyCompilationTest = Test(
            "Verify deny compilation for invalid Connect credentials")
        denyCompilationTest.addStep("Reset project", iface.newProject)
        denyCompilationTest.addStep(
            'Enter invalid Connect credentials and accept dialog by pressing "Login" button.\n'
            'Check that Connect shows Warning message complaining about only open access permissions.'
            'Close error message by pressing "Yes" button.',
            prestep=lambda: _startConectPlugin(),
            isVerifyStep=True)
        denyCompilationTest.addStep("Open WAB", lambda: openWAB())
        denyCompilationTest.addStep(
            "Create an EMPTY app and check it complains of a permission denied"
        )
        denyCompilationTest.setCleanup(closeWAB)
        tests.append(denyCompilationTest)
        localTimeoutCompilationTest = Test(
            "Verify compilation timeout due to local settings")
        localTimeoutCompilationTest.addStep("Reset project", iface.newProject)
        localTimeoutCompilationTest.addStep(
            'Enter EnterpriseTestDesktop Connect credentials and accept dialog by pressing "Login" button.\n'
            'Check that Connect is logged showing [email protected] in the bottom',
            prestep=lambda: _startConectPlugin(),
            isVerifyStep=True)
        localTimeoutCompilationTest.addStep("Open WAB", lambda: openWAB())
        localTimeoutCompilationTest.addStep(
            "Setting timeout", lambda: setNetworkTimeout(value=3000))
        localTimeoutCompilationTest.addStep(
            "Create an EMPTY app and check it complains of network timeout",
            isVerifyStep=True)
        localTimeoutCompilationTest.addStep("Close WAB", closeWAB)
        localTimeoutCompilationTest.setCleanup(resetNetworkTimeout)
        tests.append(localTimeoutCompilationTest)

        successCompilationTest = Test(
            "Verify successful compilation with EnterpriseTestDesktop")
        successCompilationTest.addStep("Reset project", iface.newProject)
        successCompilationTest.addStep(
            'Enter EnterpriseTestDesktop Connect credentials and accept dialog by pressing "Login" button.\n'
            'Check that Connect is logged showing [email protected] in the bottom',
            prestep=lambda: _startConectPlugin(),
            isVerifyStep=True)
        successCompilationTest.addStep("Open WAB", lambda: openWAB())
        successCompilationTest.addStep(
            "Create an EMPTY app and check it successfully ends",
            isVerifyStep=True)
        successCompilationTest.setCleanup(closeWAB)
        tests.append(successCompilationTest)

        # test stopCompilationTest
        def checkStartoStopButton(text=None):
            dlg = getWABDialog()
            tc.assertIn(dlg.buttonCreateOrStopApp.text(), text)

        def clickStopButton(after=5000):
            QTest.qWait(after)
            dlg = getWABDialog()
            QTest.mouseClick(dlg.buttonCreateOrStopApp, Qt.LeftButton)

        stopCompilationTest = Test(
            "Verify stop compilation with EnterpriseTestDesktop user")
        stopCompilationTest.addStep("Reset project", iface.newProject)
        stopCompilationTest.addStep(
            'Enter EnterpriseTestDesktop Connect credentials and accept dialog by pressing "Login" button.\n'
            'Check that Connect is logged showing [email protected] in the bottom',
            prestep=lambda: _startConectPlugin(),
            isVerifyStep=True)
        stopCompilationTest.addStep("Open WAB", lambda: openWAB())
        stopCompilationTest.addStep(
            "Create an EMPTY app and start compilation, then click on next step!"
        )
        stopCompilationTest.addStep("Verify if stop button is set",
                                    lambda: checkStartoStopButton(text='Stop'))
        stopCompilationTest.addStep("Click stop",
                                    lambda: clickStopButton(after=1000))
        stopCompilationTest.addStep(
            "Verify if StartApp button is set",
            lambda: checkStartoStopButton(text='CreateApp'))
        stopCompilationTest.setCleanup(closeWAB)
        tests.append(stopCompilationTest)
    except ImportError:
        pass

    return tests