diff options
author | Jeremy Cline <jcline@redhat.com> | 2020-04-14 15:27:51 -0400 |
---|---|---|
committer | Jeremy Cline <jcline@redhat.com> | 2020-04-16 19:01:32 -0400 |
commit | 401e702a9ff14bf4cc33b3ed3acf16f3c60c6945 (patch) | |
tree | da3e74f200b74f3fea6168c6597852391e7a00ca /gitlab/tests/test_config.py | |
parent | c7c431af16f256f95a9553cf2e14925fa75f7d62 (diff) | |
download | gitlab-401e702a9ff14bf4cc33b3ed3acf16f3c60c6945.tar.gz |
feat: allow an environment variable to specify config location
It can be useful (especially in scripts) to specify a configuration
location via an environment variable. If the "PYTHON_GITLAB_CFG"
environment variable is defined, treat its value as the path to a
configuration file and include it in the set of default configuration
locations.
Diffstat (limited to 'gitlab/tests/test_config.py')
-rw-r--r-- | gitlab/tests/test_config.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gitlab/tests/test_config.py b/gitlab/tests/test_config.py index 65bd300..681b3d1 100644 --- a/gitlab/tests/test_config.py +++ b/gitlab/tests/test_config.py @@ -15,6 +15,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import os import unittest import mock @@ -72,6 +73,16 @@ per_page = 200 """ +class TestEnvConfig(unittest.TestCase): + def test_env_present(self): + with mock.patch.dict(os.environ, {"PYTHON_GITLAB_CFG": "/some/path"}): + self.assertEqual(["/some/path"], config._env_config()) + + def test_env_missing(self): + with mock.patch.dict(os.environ, {}, clear=True): + self.assertEqual([], config._env_config()) + + class TestConfigParser(unittest.TestCase): @mock.patch("os.path.exists") def test_missing_config(self, path_exists): |