diff options
author | jeroen_decroos <jeroen.decroos@gmail.com> | 2019-03-07 09:07:00 -0800 |
---|---|---|
committer | jeroen_decroos <jeroen.decroos@gmail.com> | 2019-03-07 09:07:00 -0800 |
commit | 0b70da335690456a556afb9ff7a56dfca693b019 (patch) | |
tree | 4d7042ef7f2a65105ebd02af3fbe8d8d775f9c35 /gitlab/tests/test_gitlab.py | |
parent | a6e10f957aeccd7a1fd4e769f7e3acf6e4683308 (diff) | |
download | gitlab-0b70da335690456a556afb9ff7a56dfca693b019.tar.gz |
Make gitlab.Gitlab.from_config a classmethod
Diffstat (limited to 'gitlab/tests/test_gitlab.py')
-rw-r--r-- | gitlab/tests/test_gitlab.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gitlab/tests/test_gitlab.py b/gitlab/tests/test_gitlab.py index 5174bd2..fddd5ed 100644 --- a/gitlab/tests/test_gitlab.py +++ b/gitlab/tests/test_gitlab.py @@ -18,7 +18,9 @@ from __future__ import print_function +import os import pickle +import tempfile try: import unittest except ImportError: @@ -34,6 +36,17 @@ from gitlab import * # noqa from gitlab.v4.objects import * # noqa +valid_config = b"""[global] +default = one +ssl_verify = true +timeout = 2 + +[one] +url = http://one.url +private_token = ABCDEF +""" + + class TestSanitize(unittest.TestCase): def test_do_nothing(self): self.assertEqual(1, gitlab._sanitize(1)) @@ -536,3 +549,22 @@ class TestGitlab(unittest.TestCase): self.assertEqual(type(user), User) self.assertEqual(user.name, "name") self.assertEqual(user.id, 1) + + def _default_config(self): + fd, temp_path = tempfile.mkstemp() + os.write(fd, valid_config) + os.close(fd) + return temp_path + + def test_from_config(self): + config_path = self._default_config() + gitlab.Gitlab.from_config('one', [config_path]) + os.unlink(config_path) + + def test_subclass_from_config(self): + class MyGitlab(gitlab.Gitlab): + pass + config_path = self._default_config() + gl = MyGitlab.from_config('one', [config_path]) + self.assertEqual(type(gl).__name__, 'MyGitlab') + os.unlink(config_path) |