Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions 6 tests/functional/api/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ def get_all_kwargs(request):
return request.param


def test_auth_from_config(gl, temp_dir):
def test_auth_from_config(gl, gitlab_config, temp_dir):
"""Test token authentication from config file"""
test_gitlab = gitlab.Gitlab.from_config(
config_files=[temp_dir / "python-gitlab.cfg"]
)
test_gitlab = gitlab.Gitlab.from_config(config_files=[gitlab_config])
test_gitlab.auth()
assert isinstance(test_gitlab.user, gitlab.v4.objects.CurrentUser)

Expand Down
19 changes: 11 additions & 8 deletions 19 tests/functional/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,13 @@ def _wait(timeout: int = 30, step: float = 0.5, allow_fail: bool = False) -> boo


@pytest.fixture(scope="session")
def gitlab_config(
def gitlab_token(
check_is_alive,
gitlab_container_name: str,
gitlab_url: str,
docker_services,
temp_dir: pathlib.Path,
fixture_dir: pathlib.Path,
):
config_file = temp_dir / "python-gitlab.cfg"
) -> str:

start_time = time.perf_counter()
logging.info("Waiting for GitLab container to become ready.")
Expand All @@ -263,15 +261,20 @@ def gitlab_config(
f"GitLab container is now ready after {minutes} minute(s), {seconds} seconds"
)

token = set_token(gitlab_container_name, fixture_dir=fixture_dir)
return set_token(gitlab_container_name, fixture_dir=fixture_dir)


@pytest.fixture(scope="session")
def gitlab_config(gitlab_url: str, gitlab_token: str, temp_dir: pathlib.Path):
config_file = temp_dir / "python-gitlab.cfg"

config = f"""[global]
default = local
timeout = 60

[local]
url = {gitlab_url}
private_token = {token}
private_token = {gitlab_token}
api_version = 4"""

with open(config_file, "w", encoding="utf-8") as f:
Expand All @@ -281,11 +284,11 @@ def gitlab_config(


@pytest.fixture(scope="session")
def gl(gitlab_config):
def gl(gitlab_url: str, gitlab_token: str) -> gitlab.Gitlab:
"""Helper instance to make fixtures and asserts directly via the API."""

logging.info("Instantiating python-gitlab gitlab.Gitlab instance")
instance = gitlab.Gitlab.from_config("local", [gitlab_config])
instance = gitlab.Gitlab(gitlab_url, private_token=gitlab_token)

logging.info("Reset GitLab")
reset_gitlab(instance)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.