Skip to content

Commit ac46c1c

Browse files
nejchJohnVillalovos
authored andcommitted
fix(config): raise error when gitlab id provided but no config file found
1 parent 789ef81 commit ac46c1c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

gitlab/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ def __init__(
128128
if self._files:
129129
self._parse_config()
130130

131+
if self.gitlab_id and not self._files:
132+
raise GitlabConfigMissingError(
133+
f"A gitlab id was provided ({self.gitlab_id}) but no config file found"
134+
)
135+
131136
def _parse_config(self) -> None:
132137
_config = configparser.ConfigParser()
133138
_config.read(self._files)

tests/unit/test_gitlab.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import responses
2626

2727
import gitlab
28+
from gitlab.config import GitlabConfigMissingError
2829
from tests.unit import helpers
2930

3031
localhost = "http://localhost"
@@ -299,6 +300,11 @@ def test_gitlab_from_config(default_config):
299300
gitlab.Gitlab.from_config("one", [config_path])
300301

301302

303+
def test_gitlab_from_config_without_files_raises():
304+
with pytest.raises(GitlabConfigMissingError, match="non-existing"):
305+
gitlab.Gitlab.from_config("non-existing")
306+
307+
302308
def test_gitlab_subclass_from_config(default_config):
303309
class MyGitlab(gitlab.Gitlab):
304310
pass

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy