Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

test(functional): do not require config file#2397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
JohnVillalovos merged 1 commit intomainfromtest/without-config
Dec 18, 2022
Merged
Show file tree
Hide file tree
Changes fromall 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 deletionstests/functional/api/test_gitlab.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionstests/functional/conftest.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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")
defgitlab_config(
defgitlab_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

[8]ページ先頭

©2009-2025 Movatter.jp