コード例 #1
0
 def testSetIssueUrl(self):
     """Test is issue url is set"""
     issueUrl = 'http://www.example.com'
     name = 'this is the test name'
     t = Test(name)
     t.setIssueUrl(issueUrl)
     self.assertEqual(t.issueUrl, issueUrl)
コード例 #2
0
 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)
コード例 #3
0
 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)
コード例 #4
0
 def test__str___(self):
     """Test __str__ method"""
     t = Test('Test that was skipped')
     t.addStep('Skipped', lambda: False)
     tr = TestResult(t)
     self.assertEqual(
         '{}'.format(tr),
         'Test name: -Test that was skipped\nTest result:Test skipped')
コード例 #5
0
 def test__str___(self):
     """test __str__  that convert a status in readamble string."""
     t = Test('Test that skipped is set')
     t.addStep('Skipped', lambda: False)
     tr = TestResult(t)
     self.assertEqual(
         u"%s" % tr,
         'Test name: -Test that skipped is set\nTest result:Test skipped')
コード例 #6
0
 def testSkipped(self):
     """check if the skipped is correctly set."""
     t = Test('Test that skipped is set')
     t.addStep('Skipped', lambda: False)
     tr = TestResult(t)
     tr.skipped()
     self.assertEqual(tr.status, tr.SKIPPED)
     self.assertIsNone(tr.errorStep)
     self.assertIsNone(tr.errorMessage, 'PASSED')
コード例 #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 testPassed(self):
     """Check if the passed flag is correctly set"""
     t = Test('Test that passed')
     t.addStep('Passed', lambda: False)
     tr = TestResult(t)
     tr.passed()
     self.assertEqual(tr.status, tr.PASSED)
     self.assertIsNone(tr.errorStep)
     self.assertIsNone(tr.errorMessage)
コード例 #9
0
 def testFailed(self):
     """check if the fail flag is correctly set."""
     t = Test('Test that fail is set')
     t.addStep('Fail', lambda: False)
     tr = TestResult(t)
     tr.failed('fake_step', 'FAILED')
     self.assertEqual(tr.status, tr.FAILED)
     self.assertEqual(tr.errorStep, 'fake_step')
     self.assertEqual(tr.errorMessage, 'FAILED')
コード例 #10
0
 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)
コード例 #11
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)
コード例 #12
0
 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)
コード例 #13
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)
コード例 #14
0
 def _comparisonTestCompiled(n):
     test = Test("Compiled app test '%s'" % n, "Compiled app tests")
     test.addStep("Setting up project", lambda: loadTestProject("widgets"))
     test.addStep("Creating web app", lambda: _createWebAppCompiled(n), prestep = _checkConnect)
     test.addStep("Compare web app with expected app in browser",
                  prestep=lambda: _openComparisonCompiled(n))
     return test
コード例 #15
0
 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
コード例 #16
0
def functionalTests():
    try:
        from qgistester.test import Test
        from qgistester.utils import layerFromName
    except:
        return []

    def sampleMethod(self):
        pass

    sampleTest = Test("Sample test")
    sampleTest.addStep("Sample step", sampleMethod)

    return [sampleTest]
コード例 #17
0
 def _testWidget(n):
     aboutContent = widgetTestAbout.get(n, None)
     test = Test("Verify '%s' widget" % n, "Widget tests")
     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
コード例 #18
0
 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
コード例 #19
0
 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
コード例 #20
0
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]
コード例 #21
0
    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)
コード例 #22
0
    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)
コード例 #23
0
    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')

        t.addStep(description2, testFunction2, preStep, True)
        self.assertEqual(len(t.steps), 1)
        s = t.steps[0]
        self.assertEqual(s.description, description2)
        self.assertEqual(s.function, testFunction2)
        self.assertEqual(s.prestep, preStep)
        self.assertTrue(s.isVerifyStep)
コード例 #24
0
def functionalTests():
    try:
        from qgistester.test import Tests
    except:
        return []

    infoTests = Test("Verify report dialog")
    infoTests.addStep(
        "Open the reporting dialog and verify that it shows system information"
    )
    infoTests.addStep("Verify that 'Copy to clipboard' button works correctly")

    return [infoTests]
コード例 #25
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]
コード例 #26
0
def functionalTests():
    try:
        from qgistester.test import Test
        class GeoGigTest(Test):
            def __init__(self, name):
                Test.__init__(self, name)
                self.addStep("Preparing test", backupConfiguration)
                self.setCleanup(restoreConfiguration)

    except:
        return []

    tests = []


    test = GeoGigTest("Connect to endpoint")
    test.addStep("Open navigator", lambda:  _openNavigator(True))
    test.addStep("Add a new geogig server at the repositories server url")
    test.addStep("Verify the endpoint item has been correctly added (might contain child repos or not)")
    tests.append(test)

    test = GeoGigTest("Connect to wrong endpoint")
    test.addStep("Open navigator", lambda:  _openNavigator(True))
    test.addStep("Add a new geogig server at 'http://wrong.url'")
    test.addStep("Verify a warning indicating that the url is wrong is shown. Verify endpoint item is added to tree and grayed out.")
    tests.append(test)

    test = GeoGigTest("Add layer without repo")
    test.addStep("Open test data", lambda: openTestProject("points"))
    test.addStep("Open navigator", lambda:  _openNavigator(True))
    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.")
    tests.append(test)

    test = GeoGigTest("Add layer to repository")
    test.addStep("Open test data", lambda: openTestProject("points"))
    test.addStep("Create repository", lambda: _createEmptyTestRepo(True))
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Add layer 'points' to the 'empty' repository using navigator button 'Add layer")
    test.addStep("Check layer has been added to repo", _checkLayerInRepo)
    tests.append(test)

    test = GeoGigTest("Check repository log")
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Create repository", lambda: _createSimpleTestRepo())
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Check log is correctly displayed in the history tab of the GeoGig navigator")
    tests.append(test)

    test = GeoGigTest("Open repository layers in QGIS")
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("New project", iface.newProject)
    test.addStep("Add layer from the 'simple' repository into QGIS. Use the links in the repository description panel")
    test.addStep("Check layer has been added to project", _checkLayerInProject)
    tests.append(test)

    test = GeoGigTest("Open repository layers in QGIS from tree")
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("New project", iface.newProject)
    test.addStep("Add layer from the 'simple' repository into QGIS. Use the links in the layer items of the repository tree")
    test.addStep("Check layer has been added to project", _checkLayerInProject)
    tests.append(test)

    test = GeoGigTest("Open already exported layers in QGIS from tree")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export repo layer", _exportAndChangeToFirstVersion)
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Add layer from the 'simple' repository into QGIS. Use the links in the layer items of the repository tree (which should be in orange color). "
                 "Verify that is asks you for confirmation. Select 'Use branch version'", isVerifyStep = True)
    test.addStep("Check context menu info", lambda: _checkContextMenuInfo("third"))
    tests.append(test)

    test = GeoGigTest("Open already exported layers in QGIS when there are local changes")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export repo layer", _exportAndEditLayer)
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Add layer from the 'simple' repository into QGIS. Use the links in the layer items of the repository tree. "
                 "Verify it show a message in the message bar saying that the layer was already loaded", isVerifyStep = True)
    tests.append(test)

    test = GeoGigTest("Open already exported layers in QGIS to an older version, with local changes")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export repo layer", _exportChangetoFirstVersionAndEditLayer)
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Add layer from the 'simple' repository into QGIS. Use the links in the layer items of the repository tree (which should be in orange color).  "
                 "Verify that is asks you for confirmation. Select 'Use branch version'. Check it is not permitted due to local changes in the layer",
                 isVerifyStep = True)
    tests.append(test)

    test = GeoGigTest("Change layer version")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export repo layer", _exportAndChangeToFirstVersion)
    test.addStep("Change version to 'third' using the 'Change version' menu entry in the layer context menu")
    test.addStep("Check layer has been added to project", _checkLayerInProject)
    test.addStep("Check context menu info", lambda: _checkContextMenuInfo("third"))
    tests.append(test)

    test = GeoGigTest("Change layer version when there are local changes")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export repo layer", _exportAndEditLayer)
    test.addStep("Try to change version using the 'Change version' menu entry in the layer context menu."
                 "Check it is not permitted due to local changes in the layer", isVerifyStep = True)
    tests.append(test)

    test = Test("Sync with only local changes")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Export and edit repo layer", _exportAndEditLayer)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Sync with repository branch'. Sync with master branch'")
    test.addStep("Check in repo history that a new version has been created")
    tests.append(test)

    test = Test("Sync to non-master branch")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Export and edit repo layer", _exportAndEditLayer)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Sync with repository branch'. Select 'mybranch' in the branch box and sync'")
    test.addStep("Check in repo history that the 'mybranch' branch has been updated with the changes")
    tests.append(test)


    test = Test("Sync with only upstream changes")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Export repo layer", _exportAndChangeToFirstVersion)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Sync with repository branch'. Sync with master branch'")
    test.addStep("Check context menu info", lambda: _checkContextMenuInfo("third"))
    test.addStep("Check that layer has been modified")
    tests.append(test)

    test = Test("Sync with no changes at all")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export repo layer", _exportLayer)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Sync with repository branch'. Sync with master branch'")
    test.addStep("Check context menu info", lambda: _checkContextMenuInfo("third"))
    test.addStep("Check that no changes are made in the layer or the history")
    tests.append(test)

    test = Test("Merge without conflicts")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Create merge conflict", _createMergeScenario)
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Merge 'mybranch' branch into 'master' branch")
    test.addStep("Check that the merge was correctly completed")
    tests.append(test)

    test = Test("Merge with conflicts")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Create merge conflict", _createMergeConflict)
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Merge 'mybranch' branch into 'master' branch. Solve conflict")
    test.addStep("Check that the merge was correctly completed")
    tests.append(test)

    test = Test("Merge with conflicts in several layers")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createMultilayerTestRepo(True))
    test.addStep("Create merge conflict", _createMergeConflictInSeveralLayers)
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Merge 'mybranch' branch into 'master' branch. Solve conflict")
    test.addStep("Check that the merge was correctly completed")
    tests.append(test)

    test = Test("Sync with conflicts")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export and edit repo layer", _exportAndCreateConflict)
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Sync with repository branch'. Sync with master branch. Solve conflict'")
    test.addStep("Check that new version has been created in the repo history")
    tests.append(test)

    test = Test("Sync with conflict, with remove and modify")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export and edit repo layer", _exportAndCreateConflictWithRemoveAndModify)
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Sync with repository branch'. Sync with master branch. Solve conflict'")
    test.addStep("Check that new version has been created in the repo history")
    tests.append(test)

    test = Test("Sync with conflicts and null values")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export and edit repo layer", _exportAndCreateConflictWithNulls)
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Sync with repository branch'. Sync with master branch. Solve conflict with a new feature'")
    test.addStep("Check that new version has been created in the repo history")
    tests.append(test)

    test = Test("Sync with conflicts, without resolving them")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export and edit repo layer", _exportAndCreateConflict)
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Sync with repository branch'. Sync with master branch. Exit conflict dialog without solving'")
    test.addStep("Check that no new version has been created in the repo history, and the layer hasn't been modified")
    tests.append(test)

    test = Test("Sync with both local and upstream changes, without conflict")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Export and edit repo layer", _exportAndAddFeatureToLayer)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Sync with repository branch. Sync with master branch'")
    test.addStep("Check that layer has been modified and a new version has been created in the repo history")
    tests.append(test)

    test = Test("Sync with layer only in one branch")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Export repo layer", _exportLayer)
    test.addStep("Delete layer from branch", _deleteLayerFromBranch)
    test.addStep("Right click on 'points' layer and select 'GeoGig/Sync with repository branch. Verify that only 'master'branch is available")
    tests.append(test)

    test = Test("Pull with conflicts")
    test.addStep("New project", iface.newProject)
    test.addStep("Prepare test", _createConflictedPullScenario)
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Select the repository in the repository explorer. Click on the 'Pull from remote' button and pull from 'myremote' into'master' branch. It will warn you of existing conflict. Solve conflicts and verify it finishes the pull operation correctly.")
    tests.append(test)

    test = Test("Check diff viewer")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo())
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Click on latest version and select 'View changes'. Check that diff viewer works correctly")
    tests.append(test)

    test = Test("Check local diff viewer")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export and edit repo layer", _exportAndEditLayer)
    test.addStep("Right click on 'points' layer and select 'GeoGig/view local changes'. Check that diff viewer works correctly")
    tests.append(test)

    test = Test("Check export diff layer")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Add commit", _addNewCommit)
    test.addStep("Open navigator",  _openNavigator)
    test.addStep("Click on latest version in master branch and select 'Export diff as layer'. Check that layer is exported correctly")
    tests.append(test)

    test = GeoGigTest("Add layer to repository from context menu")
    test.addStep("Open test data", lambda: openTestProject("points"))
    test.addStep("Create repository", lambda: _createEmptyTestRepo(True))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Add layer using context menu")
    test.addStep("Check layer has been added to repo", _checkLayerInRepo)
    test.addStep("Check layer context menus", _checkLayerHasTrackedContextMenus)
    tests.append(test)

    test = GeoGigTest("Show version characteristics")
    test.addStep("Create repository", lambda: _createSimpleTestRepo())
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Right click on repo's last commit and select 'Show detailed description'\nVerify description is correctly shown")
    tests.append(test)

    test = GeoGigTest("Create new branch")
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Create new branch at master branch's last commit and verify it is added to history tree")
    tests.append(test)

    test = GeoGigTest("Delete branch")
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Verify that 'master' branch cannot be deleted from history tree", isVerifyStep = True)
    test.addStep("Delete 'mybranch' using repo history panel and verify the versions tree is updated")
    tests.append(test)

    test = GeoGigTest("Delete branch in repositories tree")
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Verify that 'master' branch cannot be deleted from repositories tree", isVerifyStep = True)
    test.addStep("Delete 'mybranch' from the versions tree and verify the repositories tree is updated")
    tests.append(test)

    test = GeoGigTest("Delete layer in repositories tree, in 'master' branch")
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Delete 'points' layer in 'master' branch in repositories tree, and verify the repositories tree is updated correctly")
    tests.append(test)

    test = GeoGigTest("Delete layer in tree, in non-master branch")
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Delete 'points' layer in 'mybranch' branch in repositories tree, and verify the versions tree is updated correctly")
    tests.append(test)

    test = GeoGigTest("Delete layer in tree, in all branches")
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export repo layer", _exportLayer)
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Delete 'points' layer in 'mybranch' branch in repositories tree, and verify the versions tree is updated correctly."
                 "Verify that the context menu of the layer still shows the tracked layer menus")
    test.addStep("Delete 'points' layer in 'master' branch in repositories tree, and verify the versions tree is updated correctly."
                 "Verify that the context menu of the layer shows the layer as untracked")
    tests.append(test)


    test = GeoGigTest("Create new tag")
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Create new tag at current branch's last commit and verify it is added to history tree")
    tests.append(test)

    test = GeoGigTest("Delete tag")
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Open navigator", _openNavigator)
    test.addStep("Delete 'mytag' tag and verify the versions tree is updated")
    tests.append(test)

    test = Test("Check map tools viewer")
    test.addStep("New project", iface.newProject)
    test.addStep("Create repository", lambda: _createSimpleTestRepo(True))
    test.addStep("Export layer", _exportLayer)
    test.addStep("Select the 'GeoGig/Info Tool' menu")
    test.addStep("Select layer", _selectLayer)
    test.addStep("Click on a feature and select 'View authorship'. Verify it shows authorship correctly", isVerifyStep = True)
    test.addStep("Click on a feature and select 'View versions'. Verify it shows feature versions correctly")
    tests.append(test)

    return tests
コード例 #27
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]
コード例 #28
0
    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)
コード例 #29
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 i, testProject in enumerate(utils.testProjects()):
        renderingTest = Test("Verify rendering of uploaded style (%i)" % i)
        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
コード例 #30
0
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]
コード例 #31
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
コード例 #32
0
def functionalTests():
    try:
        from qgistester.test import Test

    except:
        return []

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

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

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

    w3wTest = Test("Test w3w")
    w3wTest.addStep("Load layer", _loadLayer)
    w3wTest.addStep("Select map tool", _setTool)
    w3wTest.addStep(
        "Click within the layer polygon and verify that the computed 3 coords are 'healings.distorting.harsher'",
        isVerifyStep=True)
    w3wTest.addStep("Move map canvas",
                    lambda: iface.mapCanvas().setCenter(QgsPoint(0, 0)))
    w3wTest.addStep("Open panel", _zoomTo)
    w3wTest.addStep(
        "Enter 'healings.distorting.harsher' and click on 'zoom to'. Verify it zooms to the polygon layer"
    )
    w3wTest.addStep(
        "Click on 'remove marker' and verify it removes the marker")
    return [w3wTest]
コード例 #33
0
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]
コード例 #34
0
def functionalTests():
    try:
        from qgistester.test import Test
    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")
        if QGis.QGIS_VERSION_INT < 29900:
            layer.setRendererV2(r)
        else:
            layer.setRenderer(r)
        layer.reload()
        layer.triggerRepaint()
        iface.mapCanvas().setExtent(layer.extent())

    def _changeSize():
        layer = _layerFromName("2525")
        if QGis.QGIS_VERSION_INT < 29900:
            r = layer.rendererV2()
        else:
            r = layer.renderer()
        r.size = 80
        layer.triggerRepaint()
        iface.mapCanvas().setExtent(layer.extent())

    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'",
        _openLayerProperties)
    editWidgetTest.addStep("Toggle editing", _startEditing)
    #editWidgetTest.addStep("Open attributes table", _openAttributesTable)
    editWidgetTest.addStep(
        "Select layer in the layers tree and open its attribute table")
    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(
        "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)
    sizeChangeTest.addStep(
        "Verify that the layer is rendered with MIL-STD-2525 symbology",
        isVerifyStep=True)
    #sizeChangeTest.addStep("Change size", _changeSize)
    sizeChangeTest.addStep(
        "Open layer properties. Go to the 'Style' tab and set symbol size to 80. "
        "Close dialog by pressing 'OK' button", _openLayerProperties)
    sizeChangeTest.addStep("Verify that the size of symbols has changed")

    return [editWidgetTest, rendererTest, sizeChangeTest]
コード例 #35
0
    try:
        from qgistester.test import Test
        from qgistester.utils import layerFromName
    except:
        return []

    def sampleMethod(self):
        pass

    sampleTest = Test("Sample test")
    sampleTest.addStep("Sample step", sampleMethod)

    return [sampleTest]


class [pluginclassname]Test(unittest.TestCase):

    def testSampleTest(self):
        pass


def pluginSuite():
    suite = unittest.TestSuite()
    suite.addTests(unittest.makeSuite([pluginclassname]Test, 'test'))
    return suite

def unitTests():
    _tests = []
    _tests.extend(pluginSuite())
    return _tests
コード例 #36
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]
コード例 #37
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
            ]
コード例 #38
0
 def __init__(self, name):
     Test.__init__(self, name)
     self.addStep("Preparing test", backupConfiguration)
     self.setCleanup(restoreConfiguration)
コード例 #39
0
def functionalTests():
    try:
        from qgistester.test import Test
        from qgistester.utils import layerFromName
    except:
        return []

    def sampleMethod(self):
        pass

    plotTest = Test("Plot workflow")
    plotTest.addStep("Copy folder path", copyDatacubeFolder)
    plotTest.addStep(
        "Add data source to plugin main panel. Datacube URL has been copied to the clipboard"
    )
    plotTest.addStep("Add all layers from the ls7 coverage")
    plotTest.addStep(
        "Move to the 'Plot' tab and click the 'Select point tool' button."
        "Click on a point in the canvas. You should see a plot in the plot panel.",
        isVerifyStep=True)
    plotTest.addStep(
        "Click on the 'Select region tool'. Click and drag a small rectangle in the canvas."
        " You should see a box and whiskers plot in the plot panel",
        isVerifyStep=True)
    plotTest.addStep(
        "Move the sliders in the 'Plot' tab and verify that the plot panel reacts correctly",
        isVerifyStep=True)
    plotTest.addStep(
        "Change the parameter to plot and verify that the plot panel reacts correctly",
        isVerifyStep=True)
    plotTest.addStep(
        "Change the coverage to plot and verify that the plot panel is cleared",
        isVerifyStep=True)
    plotTest.addStep(
        "Change back the coverage to plot and verify that the plot panel shows a plot again",
        isVerifyStep=True)

    renderingTest = Test("Rendering test")
    renderingTest.addStep("Copy folder path", copyDatacubeFolder)
    renderingTest.addStep(
        "Add data source to plugin main panel. Datacube URL has been copied to the clipboard"
    )
    renderingTest.addStep("Add one layer from the ls7 coverage")
    renderingTest.addStep(
        "Modify the rendering of the ls7 coverage so r=green, g=blue, b=nir. Click on apply and verify the rendering changes",
        isVerifyStep=True)
    renderingTest.addStep(
        "Add the remaining layer from the ls7 coverage and verify in its properties that it uses bands 2, 3 and 4 for the rendering",
        isVerifyStep=True)

    wrongEndpointTest = Test("Rendering test")
    wrongEndpointTest.addStep(
        "Add wrong source to plugin main panel, entering 'wrong' in the endpoint dialog. Verify that a warning message is shown"
    )

    mosaicParametersTest = Test("Mosaic parameters test")
    mosaicParametersTest.addStep("Copy folder path", copyDatacubeFolder)
    mosaicParametersTest.addStep(
        "Add data source to plugin main panel. Datacube URL has been copied to the clipboard"
    )
    mosaicParametersTest.addStep(
        "Open the mosaic panel and try to create a mosaic. Verify it complains that extent is not configured",
        isVerifyStep=True)
    mosaicParametersTest.addStep(
        "Fill the extent values clicking on 'Canvas extent'. Try to create a mosaic. Verify it complains that there are no coverages.",
        isVerifyStep=True)
    mosaicParametersTest.addStep(
        "Add one layer from the ls7 coverage and then remove it from the QGIS project. Try to create the mosaic and verify a warning is shown",
        isVerifyStep=True)

    mosaicTest = Test("Mosaic parameters test")
    mosaicTest.addStep("Copy folder path", copyDatacubeFolder)
    mosaicTest.addStep(
        "Add data source to plugin main panel. Datacube URL has been copied to the clipboard"
    )
    mosaicTest.addStep("Add one layer from the ls7 coverage")
    mosaicTest.addStep(
        "Open the mosaic panel. Click on 'Select on canvas'. Click and drag on the canvas to define a extent. Click on 'Create mosaic'. Verify the mosaic is created and added"
    )

    return [
        plotTest, renderingTest, wrongEndpointTest, mosaicTest,
        mosaicParametersTest
    ]
コード例 #40
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]
コード例 #41
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
コード例 #42
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
コード例 #43
0
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]
コード例 #44
0
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]
コード例 #45
0
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]
コード例 #46
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
コード例 #47
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]
コード例 #48
0
 def __init__(self, name, category = "General"):
     Test.__init__(self, name, category)
     self.addStep("Preparing test", backupConfiguration)
     self.setCleanup(restoreConfiguration)
コード例 #49
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]
コード例 #50
0
def functionalTests():
    try:
        from qgistester.test import Test
    except:
        return []

    initial_models = None
    final_models = None

    def open_schema_import_dialog(models):
        plugin = qgis.utils.plugins['asistente_ladm_col']
        plugin.show_dlg_import_schema(**models)

    def open_schema_import_dialog_model1():
        open_schema_import_dialog({'selected_models': [LADMColModelRegistry().model(LADMNames.SUPPLIES_MODEL_KEY).full_name()]})

    def open_schema_import_dialog_model2():
        open_schema_import_dialog({'selected_models': [LADMColModelRegistry().model(LADMNames.SNR_DATA_SUPPLIES_MODEL_KEY).full_name()]})

    def get_initial_models_in_cache():
        global initial_models
        initial_models = get_models_in_cache()

    def get_models_in_cache():
        plugin = qgis.utils.plugins['asistente_ladm_col']
        models = [record[QueryNames.MODEL] for record in plugin.app.core.get_cached_layers()]
        models = set(models)
        if None in models:
            models.remove(None)
        return models

    def get_final_models_in_cache():
        global final_models
        final_models = get_models_in_cache()

    def validate_initial_final_models():
        global initial_models
        global final_models
        assert len(final_models -initial_models) > 0, "Modelos iniciales: {}, Modelos finales: {}".format(initial_models, final_models)

    layer_relations_cache_test = Test(
        'CACHE DE CAPAS Y RELACIONES DEBE SER RECONSTRUIDO SI SE EJECUTÓ BIEN UN SCHEMA IMPORT.')
    layer_relations_cache_test.addStep("""INSTRUCCIONES:<br>
    1. Se abrirá por 1era vez el diálogo Schema Import automáticamente.<br> 
       1.a Selecciona una conexión nueva (se recomienda a GPKG).<br>
       1.b Dale click a Run para importar la estructura pre-seleccionada a la GPKG.<br>
       1.c Cierra el diálogo.<br>
    2. Se abrirá por 2da vez el diálogo Schema Import automáticamente.<br>
       2.a Dale click a Run para importar la estructura pre-seleccionada a la GPKG.<br>
       2.b Cierra el diálogo.<br><br>
    Luego de esto, el test evaluará automáticamente si el caché de capas y relaciones se reconstruyó.
      """)
    layer_relations_cache_test.addStep('Usar diálogo Schema Import (1era vez)...', open_schema_import_dialog_model1)
    layer_relations_cache_test.addStep('Obtener modelos en 1er Schema Import', get_initial_models_in_cache)
    layer_relations_cache_test.addStep('¿Todo va bien?', isVerifyStep=True)
    layer_relations_cache_test.addStep('Usar diálogo Schema Import (2da vez)...', open_schema_import_dialog_model2)
    layer_relations_cache_test.addStep('¿Hasta acá todo va bien?', isVerifyStep=True)
    layer_relations_cache_test.addStep('Obtener modelos en 2do Schema Import', get_final_models_in_cache)
    layer_relations_cache_test.addStep('Se reconstruyó el cache? Esto es, hay más modelos finales que iniciales?', validate_initial_final_models)

    return [layer_relations_cache_test]
コード例 #51
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