Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Aug 27, 2020
1 parent d7b1287 commit 5a7e3c1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/src/python/test_qgsserver_settings.py
Expand Up @@ -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.