summaryrefslogtreecommitdiff
path: root/gitlab/tests/test_config.py
diff options
context:
space:
mode:
authorJoost Evertse <joustie@gmail.com>2019-01-21 13:36:56 +0100
committerGitHub <noreply@github.com>2019-01-21 13:36:56 +0100
commitb51d2969ad34a9aad79e42a69f275caf2a4059cb (patch)
treea4519d935a0b5ae5361cb178318402e09da17d75 /gitlab/tests/test_config.py
parent53f7de7bfe0056950a8e7271632da3f89e3ba3b3 (diff)
parent52d76312660109d3669d459b11b448a3a60b9603 (diff)
downloadgitlab-b51d2969ad34a9aad79e42a69f275caf2a4059cb.tar.gz
Merge branch 'master' into master
Diffstat (limited to 'gitlab/tests/test_config.py')
-rw-r--r--gitlab/tests/test_config.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/gitlab/tests/test_config.py b/gitlab/tests/test_config.py
index 0b585e8..d1e668e 100644
--- a/gitlab/tests/test_config.py
+++ b/gitlab/tests/test_config.py
@@ -76,11 +76,20 @@ per_page = 200
class TestConfigParser(unittest.TestCase):
+ @mock.patch('os.path.exists')
+ def test_missing_config(self, path_exists):
+ path_exists.return_value = False
+ with self.assertRaises(config.GitlabConfigMissingError):
+ config.GitlabConfigParser('test')
+
+ @mock.patch('os.path.exists')
@mock.patch('six.moves.builtins.open')
- def test_invalid_id(self, m_open):
+ def test_invalid_id(self, m_open, path_exists):
fd = six.StringIO(no_default_config)
fd.close = mock.Mock(return_value=None)
m_open.return_value = fd
+ path_exists.return_value = True
+ config.GitlabConfigParser('there')
self.assertRaises(config.GitlabIDError, config.GitlabConfigParser)
fd = six.StringIO(valid_config)
@@ -90,12 +99,15 @@ class TestConfigParser(unittest.TestCase):
config.GitlabConfigParser,
gitlab_id='not_there')
+ @mock.patch('os.path.exists')
@mock.patch('six.moves.builtins.open')
- def test_invalid_data(self, m_open):
+ def test_invalid_data(self, m_open, path_exists):
fd = six.StringIO(missing_attr_config)
fd.close = mock.Mock(return_value=None,
side_effect=lambda: fd.seek(0))
m_open.return_value = fd
+ path_exists.return_value = True
+
config.GitlabConfigParser('one')
config.GitlabConfigParser('one')
self.assertRaises(config.GitlabDataError, config.GitlabConfigParser,
@@ -107,11 +119,13 @@ class TestConfigParser(unittest.TestCase):
self.assertEqual('Unsupported per_page number: 200',
emgr.exception.args[0])
+ @mock.patch('os.path.exists')
@mock.patch('six.moves.builtins.open')
- def test_valid_data(self, m_open):
+ def test_valid_data(self, m_open, path_exists):
fd = six.StringIO(valid_config)
fd.close = mock.Mock(return_value=None)
m_open.return_value = fd
+ path_exists.return_value = True
cp = config.GitlabConfigParser()
self.assertEqual("one", cp.gitlab_id)