Skip to content

Commit 70c558d

Browse files
committed
fix: update api tests for GL 16.9
- Make sure we're testing python-gitlab functionality, make sure we're not awaiting on Gitlab Async functions - Decouple and improve test stability Signed-off-by: Tim Knight <tim.knight1@engineering.digital.dwp.gov.uk>
1 parent 1f0343c commit 70c558d

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

tests/functional/api/test_merge_requests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import datetime
22
import time
3+
from datetime import date, timedelta
34

45
import pytest
56

@@ -166,8 +167,13 @@ def test_project_merge_request_approval_rules(group, project):
166167

167168

168169
def test_merge_request_reset_approvals(gitlab_url, project):
170+
<<<<<<< HEAD
169171
today = datetime.date.today()
170172
future_date = today + datetime.timedelta(days=4)
173+
=======
174+
today = date.today()
175+
future_date = today + timedelta(days=4)
176+
>>>>>>> e6ba727d (fix: update api tests for GL 16.9)
171177
bot = project.access_tokens.create(
172178
{"name": "bot", "scopes": ["api"], "expires_at": future_date.isoformat()}
173179
)

tests/functional/api/test_users.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
https://docs.gitlab.com/ee/api/users.html#delete-authentication-identity-from-user
55
"""
66

7+
<<<<<<< HEAD
78
import datetime
89
import time
10+
=======
11+
import time
12+
from datetime import date, timedelta
13+
>>>>>>> e6ba727d (fix: update api tests for GL 16.9)
914

1015
import requests
1116

@@ -161,8 +166,13 @@ def test_user_custom_attributes(gl, user):
161166

162167

163168
def test_user_impersonation_tokens(gl, user):
169+
<<<<<<< HEAD
164170
today = datetime.date.today()
165171
future_date = today + datetime.timedelta(days=4)
172+
=======
173+
today = date.today()
174+
future_date = today + timedelta(days=4)
175+
>>>>>>> e6ba727d (fix: update api tests for GL 16.9)
166176

167177
token = user.impersonationtokens.create(
168178
{

tests/functional/cli/test_cli_repository.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@ def test_list_merge_request_commits(gitlab_cli, merge_request, project):
7777

7878

7979
def test_commit_merge_requests(gitlab_cli, project, merge_request):
80+
<<<<<<< HEAD
8081
"""This tests the `project-commit merge-requests` command and also tests
8182
that we can print the result using the `json` formatter"""
8283

84+
=======
85+
>>>>>>> e6ba727d (fix: update api tests for GL 16.9)
8386
# Pause to let GL catch up (happens on hosted too, sometimes takes a while for server to be ready to merge)
8487
time.sleep(30)
8588

tests/functional/cli/test_cli_v4.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
<<<<<<< HEAD
12
import datetime
3+
=======
4+
>>>>>>> e6ba727d (fix: update api tests for GL 16.9)
25
import os
36
import time
47

@@ -243,6 +246,23 @@ def test_accept_request_merge(gitlab_cli, project):
243246
# Pause to let GL catch up (happens on hosted too, sometimes takes a while for server to be ready to merge)
244247
time.sleep(30)
245248

249+
<<<<<<< HEAD
250+
=======
251+
if mr.detailed_merge_status == "not_approved":
252+
approve_cmd = [
253+
"project-merge-request",
254+
"approve",
255+
"--project-id",
256+
project.id,
257+
"--iid",
258+
mr.iid,
259+
]
260+
gitlab_cli(approve_cmd)
261+
262+
# Pause to let GL catch up (happens on hosted too, sometimes takes a while for server to be ready to merge)
263+
time.sleep(5)
264+
265+
>>>>>>> e6ba727d (fix: update api tests for GL 16.9)
246266
approve_cmd = [
247267
"project-merge-request",
248268
"merge",

tests/functional/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ def _make_merge_request(*, source_branch: str, create_pipeline: bool = False):
389389
}
390390
)
391391

392+
<<<<<<< HEAD
393+
=======
394+
# Helps with Debugging why MRs fail to merge resulting in 405 from downstream tests
395+
project.approvalrules.list()
396+
397+
>>>>>>> e6ba727d (fix: update api tests for GL 16.9)
392398
if create_pipeline:
393399
project.files.create(
394400
{

0 commit comments

Comments
 (0)