| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5f8b8f5 commit 43c2dda
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,11 +15,9 @@ def get_all_kwargs(request): | |||
| 15 | 15 | return request.param | |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | - def test_auth_from_config(gl, temp_dir): | ||
| 18 | + def test_auth_from_config(gl, gitlab_config, temp_dir): | ||
| 19 | 19 | """Test token authentication from config file""" | |
| 20 | - test_gitlab = gitlab.Gitlab.from_config( | ||
| 21 | - config_files=[temp_dir / "python-gitlab.cfg"] | ||
| 22 | - ) | ||
| 20 | + test_gitlab = gitlab.Gitlab.from_config(config_files=[gitlab_config]) | ||
| 23 | 21 | test_gitlab.auth() | |
| 24 | 22 | assert isinstance(test_gitlab.user, gitlab.v4.objects.CurrentUser) | |
| 25 | 23 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -236,15 +236,13 @@ def _wait(timeout: int = 30, step: float = 0.5, allow_fail: bool = False) -> boo | |||
| 236 | 236 | ||
| 237 | 237 | ||
| 238 | 238 | @pytest.fixture(scope="session") | |
| 239 | - def gitlab_config( | ||
| 239 | + def gitlab_token( | ||
| 240 | 240 | check_is_alive, | |
| 241 | 241 | gitlab_container_name: str, | |
| 242 | 242 | gitlab_url: str, | |
| 243 | 243 | docker_services, | |
| 244 | - temp_dir: pathlib.Path, | ||
| 245 | 244 | fixture_dir: pathlib.Path, | |
| 246 | - ): | ||
| 247 | - config_file = temp_dir / "python-gitlab.cfg" | ||
| 245 | + ) -> str: | ||
| 248 | 246 | ||
| 249 | 247 | start_time = time.perf_counter() | |
| 250 | 248 | logging.info("Waiting for GitLab container to become ready.") | |
@@ -263,15 +261,20 @@ def gitlab_config( | |||
| 263 | 261 | f"GitLab container is now ready after {minutes} minute(s), {seconds} seconds" | |
| 264 | 262 | ) | |
| 265 | 263 | ||
| 266 | - token = set_token(gitlab_container_name, fixture_dir=fixture_dir) | ||
| 264 | + return set_token(gitlab_container_name, fixture_dir=fixture_dir) | ||
| 265 | + | ||
| 266 | + | ||
| 267 | + @pytest.fixture(scope="session") | ||
| 268 | + def gitlab_config(gitlab_url: str, gitlab_token: str, temp_dir: pathlib.Path): | ||
| 269 | + config_file = temp_dir / "python-gitlab.cfg" | ||
| 267 | 270 | ||
| 268 | 271 | config = f"""[global] | |
| 269 | 272 | default = local | |
| 270 | 273 | timeout = 60 | |
| 271 | 274 | ||
| 272 | 275 | [local] | |
| 273 | 276 | url = {gitlab_url} | |
| 274 | - private_token = {token} | ||
| 277 | + private_token = {gitlab_token} | ||
| 275 | 278 | api_version = 4""" | |
| 276 | 279 | ||
| 277 | 280 | with open(config_file, "w", encoding="utf-8") as f: | |
@@ -281,11 +284,11 @@ def gitlab_config( | |||
| 281 | 284 | ||
| 282 | 285 | ||
| 283 | 286 | @pytest.fixture(scope="session") | |
| 284 | - def gl(gitlab_config): | ||
| 287 | + def gl(gitlab_url: str, gitlab_token: str) -> gitlab.Gitlab: | ||
| 285 | 288 | """Helper instance to make fixtures and asserts directly via the API.""" | |
| 286 | 289 | ||
| 287 | 290 | logging.info("Instantiating python-gitlab gitlab.Gitlab instance") | |
| 288 | - instance = gitlab.Gitlab.from_config("local", [gitlab_config]) | ||
| 291 | + instance = gitlab.Gitlab(gitlab_url, private_token=gitlab_token) | ||
| 289 | 292 | ||
| 290 | 293 | logging.info("Reset GitLab") | |
| 291 | 294 | reset_gitlab(instance) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments