Skip to content
Permalink
Browse files

Travis won: ported all test cases to Python

and disabled C++ companion test (still useful locally and
for debugging)

For the curious: QTemporaryFile is not working as expected
  • Loading branch information
elpaso committed Nov 9, 2016
1 parent 36d827a commit 57aa7fd710594da9c3fa0990368640c26f36cdc6
@@ -24,4 +24,4 @@ if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then
chmod -R ugo-w ~/.ccache
fi

xvfb-run ctest -V -E 'qgis_openstreetmaptest|qgis_wcsprovidertest|qgis_ziplayertest|PyQgsDBManagerGpkg' -S ./qgis-test-travis.ctest --output-on-failure
xvfb-run ctest -V -E 'qgis_filedownloader|qgis_openstreetmaptest|qgis_wcsprovidertest|qgis_ziplayertest|PyQgsDBManagerGpkg' -S ./qgis-test-travis.ctest --output-on-failure
@@ -25,5 +25,5 @@ fi

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

xvfb-run ctest -V -E "qgis_openstreetmaptest|qgis_wcsprovidertest|qgis_ziplayertest|qgis_ogcutilstest|$(cat ${DIR}/blacklist.txt | paste -sd '|' -)" -S ./qgis-test-travis.ctest --output-on-failure
xvfb-run ctest -V -E "qgis_filedownloader|qgis_openstreetmaptest|qgis_wcsprovidertest|qgis_ziplayertest|qgis_ogcutilstest|$(cat ${DIR}/blacklist.txt | paste -sd '|' -)" -S ./qgis-test-travis.ctest --output-on-failure
# xvfb-run ctest -V -E "qgis_openstreetmaptest|qgis_wcsprovidertest" -S ./qgis-test-travis.ctest --output-on-failure
@@ -139,7 +139,7 @@ void TestQgsFileDownloader::init()
mError = false;
mCompleted = false;
mExited = false;
mTempFile = new QTemporaryFile( QDir::currentPath() + QDir::separator() + "qgs_filedownloader" );
mTempFile = new QTemporaryFile( );
Q_ASSERT( mTempFile->open() );
mTempFile->close();
}
@@ -61,6 +61,7 @@ def test_validDownload(self):
"""Tests a valid download"""
destination = tempfile.mktemp()
self._make_download('http://www.qgis.org', destination)
self.assertTrue(self.exited_was_called)
self.assertTrue(self.completed_was_called)
self.assertTrue(self.progress_was_called)
self.assertFalse(self.canceled_was_called)
@@ -72,6 +73,7 @@ def test_inValidDownload(self):
"""Tests an invalid download"""
destination = tempfile.mktemp()
self._make_download('http://www.doesnotexistofthatimsure.qgis', destination)
self.assertTrue(self.exited_was_called)
self.assertFalse(self.completed_was_called)
self.assertTrue(self.progress_was_called)
self.assertFalse(self.canceled_was_called)
@@ -83,15 +85,45 @@ def test_dowloadCanceled(self):
"""Tests user canceled download"""
destination = tempfile.mktemp()
self._make_download('https://github.com/qgis/QGIS/archive/master.zip', destination, True)
self.assertTrue(self.exited_was_called)
self.assertFalse(self.completed_was_called)
self.assertTrue(self.canceled_was_called)
self.assertFalse(self.error_was_called)
self.assertFalse(os.path.isfile(destination))

def test_InvalidUrl(self):
destination = tempfile.mktemp()
self._make_download('xyz://www', destination)
self.assertTrue(self.exited_was_called)
self.assertFalse(self.completed_was_called)
self.assertFalse(self.canceled_was_called)
self.assertTrue(self.error_was_called)
self.assertFalse(os.path.isfile(destination))
self.assertEqual(self.error_args[1], [u"Network error 301: Protocol \"xyz\" is unknown"])

def test_InvalidFile(self):
self._make_download('https://github.com/qgis/QGIS/archive/master.zip', "")
self.assertTrue(self.exited_was_called)
self.assertFalse(self.completed_was_called)
self.assertFalse(self.canceled_was_called)
self.assertTrue(self.error_was_called)
self.assertEqual(self.error_args[1], [u"Cannot open output file: "])

def test_BlankUrl(self):
destination = tempfile.mktemp()
self._make_download('', destination)
self.assertTrue(self.exited_was_called)
self.assertFalse(self.completed_was_called)
self.assertFalse(self.canceled_was_called)
self.assertTrue(self.error_was_called)
self.assertFalse(os.path.isfile(destination))
self.assertEqual(self.error_args[1], [u"Network error 301: Protocol \"\" is unknown"])

def ssl_compare(self, name, url, error):
destination = tempfile.mktemp()
self._make_download(url, destination)
msg = "Failed in %s: %s" % (name, url)
self.assertTrue(self.exited_was_called)
self.assertFalse(self.completed_was_called, msg)
self.assertFalse(self.canceled_was_called, msg)
self.assertTrue(self.error_was_called, msg)

0 comments on commit 57aa7fd

Please sign in to comment.
You can’t perform that action at this time.