| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ac46c1c commit 1ef7018
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -137,6 +137,12 @@ def _parse_config(self) -> None: | |||
| 137 | 137 | _config = configparser.ConfigParser() | |
| 138 | 138 | _config.read(self._files) | |
| 139 | 139 | ||
| 140 | + if self.gitlab_id and not _config.has_section(self.gitlab_id): | ||
| 141 | + raise GitlabDataError( | ||
| 142 | + f"A gitlab id was provided ({self.gitlab_id}) " | ||
| 143 | + "but no config section found" | ||
| 144 | + ) | ||
| 145 | + | ||
| 140 | 146 | if self.gitlab_id is None: | |
| 141 | 147 | try: | |
| 142 | 148 | self.gitlab_id = _config.get("global", "default") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,7 @@ | |||
| 25 | 25 | import responses | |
| 26 | 26 | ||
| 27 | 27 | import gitlab | |
| 28 | - from gitlab.config import GitlabConfigMissingError | ||
| 28 | + from gitlab.config import GitlabConfigMissingError, GitlabDataError | ||
| 29 | 29 | from tests.unit import helpers | |
| 30 | 30 | ||
| 31 | 31 | localhost = "http://localhost" | |
@@ -305,6 +305,11 @@ def test_gitlab_from_config_without_files_raises(): | |||
| 305 | 305 | gitlab.Gitlab.from_config("non-existing") | |
| 306 | 306 | ||
| 307 | 307 | ||
| 308 | + def test_gitlab_from_config_with_wrong_gitlab_id_raises(default_config): | ||
| 309 | + with pytest.raises(GitlabDataError, match="non-existing"): | ||
| 310 | + gitlab.Gitlab.from_config("non-existing", [default_config]) | ||
| 311 | + | ||
| 312 | + | ||
| 308 | 313 | def test_gitlab_subclass_from_config(default_config): | |
| 309 | 314 | class MyGitlab(gitlab.Gitlab): | |
| 310 | 315 | pass | |
| Back | FazBrowse Home | New Git URL |
0 commit comments