Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Travis test nonsense
  • Loading branch information
nyalldawson committed Apr 15, 2020
1 parent bfadf47 commit 606fa85
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions tests/src/python/test_qgsprocessexecutable.py
Expand Up @@ -57,25 +57,30 @@ def run_process(self, arguments):

def testNoArgs(self):
rc, output, err = self.run_process([])
self.assertEqual(rc, 0)
self.assertIn('Available commands', output)
self.assertFalse(err)
if os.environ.get('TRAVIS', '') != 'true':
# Travis DOES have errors, due to QStandardPaths: XDG_RUNTIME_DIR not set warnings raised by Qt
self.assertFalse(err)
self.assertEqual(rc, 0)

def testPlugins(self):
rc, output, err = self.run_process(['plugins'])
self.assertEqual(rc, 0)
self.assertIn('available plugins', output.lower())
self.assertIn('processing', output.lower())
self.assertNotIn('metasearch', output.lower())
self.assertFalse(err)
if os.environ.get('TRAVIS', '') != 'true':
# Travis DOES have errors, due to QStandardPaths: XDG_RUNTIME_DIR not set warnings raised by Qt
self.assertFalse(err)
self.assertEqual(rc, 0)

def testAlgorithmList(self):
rc, output, err = self.run_process(['list'])
self.assertEqual(rc, 0)
self.assertIn('available algorithms', output.lower())
self.assertIn('gdal:aspect', output.lower())
self.assertIn('native:reprojectlayer', output.lower())
self.assertFalse(err)
if os.environ.get('TRAVIS', '') != 'true':
# Travis DOES have errors, due to QStandardPaths: XDG_RUNTIME_DIR not set warnings raised by Qt
self.assertFalse(err)
self.assertEqual(rc, 0)

def testAlgorithmHelpNoAlg(self):
rc, output, err = self.run_process(['help'])
Expand All @@ -85,44 +90,52 @@ def testAlgorithmHelpNoAlg(self):

def testAlgorithmHelp(self):
rc, output, err = self.run_process(['help', 'native:centroids'])
self.assertEqual(rc, 0)
self.assertIn('representing the centroid', output.lower())
self.assertIn('argument type', output.lower())
self.assertFalse(err)
if os.environ.get('TRAVIS', '') != 'true':
# Travis DOES have errors, due to QStandardPaths: XDG_RUNTIME_DIR not set warnings raised by Qt
self.assertFalse(err)
self.assertEqual(rc, 0)

def testAlgorithmRunNoAlg(self):
rc, output, err = self.run_process(['run'])
self.assertEqual(rc, 1)
self.assertIn('algorithm id or model file not specified', err.lower())
self.assertFalse(output)
self.assertEqual(rc, 1)

def testAlgorithmRunNoArgs(self):
rc, output, err = self.run_process(['run', 'native:centroids'])
self.assertEqual(rc, 1)
self.assertIn('the following mandatory parameters were not specified', err.lower())
self.assertIn('inputs', output.lower())
self.assertEqual(rc, 1)

def testAlgorithmRun(self):
output_file = self.TMP_DIR + '/polygon_centroid.shp'
rc, output, err = self.run_process(['run', 'native:centroids', '--INPUT={}'.format(TEST_DATA_DIR + '/polys.shp'), '--ALL_PARTS=false', '--OUTPUT={}'.format(output_file)])
self.assertEqual(rc, 0)
self.assertFalse(err)
if os.environ.get('TRAVIS', '') != 'true':
# Travis DOES have errors, due to QStandardPaths: XDG_RUNTIME_DIR not set warnings raised by Qt
self.assertFalse(err)
self.assertIn('0...10...20...30...40...50...60...70...80...90', output.lower())
self.assertIn('results', output.lower())
self.assertIn('OUTPUT:\t' + output_file, output)
self.assertTrue(os.path.exists(output_file))
self.assertEqual(rc, 0)

def testModelHelp(self):
rc, output, err = self.run_process(['help', TEST_DATA_DIR + '/test_model.model3'])
if os.environ.get('TRAVIS', '') != 'true':
# Travis DOES have errors, due to QStandardPaths: XDG_RUNTIME_DIR not set warnings raised by Qt
self.assertFalse(err)
self.assertEqual(rc, 0)
self.assertIn('model description', output.lower())
self.assertFalse(err)

def testModelRun(self):
output_file = self.TMP_DIR + '/model_output.shp'
rc, output, err = self.run_process(['run', TEST_DATA_DIR + '/test_model.model3', '--FEATS={}'.format(TEST_DATA_DIR + '/polys.shp'), '--native:centroids_1:CENTROIDS={}'.format(output_file)])
if os.environ.get('TRAVIS', '') != 'true':
# Travis DOES have errors, due to QStandardPaths: XDG_RUNTIME_DIR not set warnings raised by Qt
self.assertFalse(err)
self.assertEqual(rc, 0)
self.assertFalse(err)
self.assertIn('0...10...20...30...40...50...60...70...80...90', output.lower())
self.assertIn('results', output.lower())
self.assertTrue(os.path.exists(output_file))
Expand Down

0 comments on commit 606fa85

Please sign in to comment.