Skip to content
Permalink
Browse files

Add unit test

  • Loading branch information
pblottiere committed Aug 27, 2020
1 parent d7b1287 commit 5a7e3c174ac576426e8d5f97b4610b1583927eb5
Showing with 28 additions and 0 deletions.
  1. +28 −0 tests/src/python/test_qgsserver_settings.py
@@ -236,6 +236,34 @@ def test_options_path_conf1(self):
# clear environment
os.environ.pop(env)

def test_env_actual(self):
env = "QGIS_SERVER_PROJECTS_DIRECTORIES"
env2 = "QGIS_SERVER_PROJECTS_PG_CONNECTIONS"

os.environ[env] = "/tmp/initial"
os.environ[env2] = "pg:initial"

# test intial value
self.settings.load()
self.assertEqual(self.settings.projectsDirectories(), "/tmp/initial")
self.assertEqual(self.settings.projectsPgConnections(), "pg:initial")

# set new environment variable
os.environ[env] = "/tmp/new"
os.environ[env2] = "pg:new"

# test new environment variable
self.assertEqual(self.settings.projectsDirectories(), "/tmp/new")
self.assertEqual(self.settings.projectsPgConnections(), "pg:new")

# current environment variable are popped
os.environ.pop(env)
os.environ.pop(env2)

# fallback to initial values
self.assertEqual(self.settings.projectsDirectories(), "/tmp/initial")
self.assertEqual(self.settings.projectsPgConnections(), "pg:initial")


if __name__ == '__main__':
unittest.main()

0 comments on commit 5a7e3c1

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