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

Commit67ab24f

Browse files
nejchJohnVillalovos
authored andcommitted
test(functional): simplify token creation
1 parent346cf76 commit67ab24f

File tree

3 files changed

+9
-26
lines changed

3 files changed

+9
-26
lines changed

‎tests/functional/conftest.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,6 @@ def reset_gitlab(gl: gitlab.Gitlab) -> None:
5050
helpers.safe_delete(user,hard_delete=True)
5151

5252

53-
defset_token(container,fixture_dir):
54-
logging.info("Creating API token.")
55-
set_token_rb=fixture_dir/"set_token.rb"
56-
57-
withopen(set_token_rb,"r",encoding="utf-8")asf:
58-
set_token_command=f.read().strip()
59-
60-
rails_command= [
61-
"docker",
62-
"exec",
63-
container,
64-
"gitlab-rails",
65-
"runner",
66-
set_token_command,
67-
]
68-
output=check_output(rails_command).decode().strip()
69-
logging.info("Finished creating API token.")
70-
71-
returnoutput
72-
73-
7453
defpytest_report_collectionfinish(config,startdir,items):
7554
return [
7655
"",
@@ -157,7 +136,7 @@ def _wait(timeout=30, step=0.5):
157136

158137

159138
@pytest.fixture(scope="session")
160-
defgitlab_config(check_is_alive,docker_ip,docker_services,temp_dir,fixture_dir):
139+
defgitlab_config(check_is_alive,docker_ip,docker_services,temp_dir):
161140
config_file=temp_dir/"python-gitlab.cfg"
162141
port=docker_services.port_for("gitlab",80)
163142

@@ -174,15 +153,13 @@ def gitlab_config(check_is_alive, docker_ip, docker_services, temp_dir, fixture_
174153
f"GitLab container is now ready after{minutes} minute(s),{seconds} seconds"
175154
)
176155

177-
token=set_token("gitlab-test",fixture_dir=fixture_dir)
178-
179156
config=f"""[global]
180157
default = local
181158
timeout = 60
182159
183160
[local]
184161
url = http://{docker_ip}:{port}
185-
private_token ={token}
162+
private_token =python-gitlab-token
186163
api_version = 4"""
187164

188165
withopen(config_file,"w",encoding="utf-8")asf:

‎tests/functional/fixtures/docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ services:
3131
gitlab_exporter['enable'] =false
3232
grafana['enable'] =false
3333
letsencrypt['enable'] =false
34+
entrypoint:
35+
-/bin/sh
36+
--c
37+
-chmod 644 /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/* && /assets/wrapper
38+
volumes:
39+
-${PWD}/tests/functional/fixtures/set_token.rb:/opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/003_set_token.rb
3440
ports:
3541
-'8080:80'
3642
-'2222:22'

‎tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ skip_missing_interpreters = True
55
envlist = py310,py39,py38,py37,flake8,black,twine-check,mypy,isort,cz,pylint
66

77
[testenv]
8-
passenv = GITLAB_IMAGE GITLAB_TAG PY_COLORS NO_COLOR FORCE_COLOR DOCKER_HOST
8+
passenv = GITLAB_IMAGE GITLAB_TAG PY_COLORS NO_COLOR FORCE_COLOR DOCKER_HOST PWD
99
setenv =VIRTUAL_ENV={envdir}
1010
whitelist_externals = true
1111
usedevelop = True

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp