Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Jul 31, 2017
1 parent 75811ef commit 92bad92
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/src/python/test_qgsproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,29 @@ def test_zip_new_project(self):

def test_zip_invalid_path(self):
project = QgsProject()
self.assertFalse(project.zip())
self.assertFalse(project.zip("/fake/test.zip"))
self.assertFalse(project.zip(""))

def test_zip_filename(self):
tmpFile = QTemporaryFile()
tmpFile.open()
tmpFile.close()
os.remove(tmpFile.fileName())

project = QgsProject()
self.assertFalse(project.zip())

project.setZipFileName(tmpFile.fileName())
self.assertTrue(project.zip())
self.assertTrue(os.path.isfile(tmpFile.fileName()))

def test_unzip_invalid_path(self):
project = QgsProject()
self.assertFalse(project.unzip())
self.assertFalse(project.unzip(""))
self.assertFalse(project.unzip("/fake/test.zip"))

def test_zip_unzip(self):
tmpFile = QTemporaryFile()
tmpFile.open()
Expand All @@ -719,7 +739,11 @@ def test_zip_unzip(self):
self.assertTrue(project.zip(tmpFile.fileName()))

project2 = QgsProject()
self.assertFalse(project2.unzipped())
self.assertTrue(project2.zipFileName() == "")
self.assertTrue(project2.unzip(tmpFile.fileName()))
self.assertTrue(project2.unzipped())
self.assertTrue(project2.zipFileName() == tmpFile.fileName())
layers = project2.mapLayers()

self.assertEqual(len(layers.keys()), 2)
Expand Down

0 comments on commit 92bad92

Please sign in to comment.