1
+ import logging
1
2
import os
2
3
import time
4
+ from datetime import date
5
+
6
+ branch = "branch-cli-v4"
3
7
4
8
5
9
def test_create_project (gitlab_cli ):
@@ -22,28 +26,6 @@ def test_update_project(gitlab_cli, project):
22
26
assert description in ret .stdout
23
27
24
28
25
- def test_create_ci_lint (gitlab_cli , valid_gitlab_ci_yml ):
26
- cmd = ["ci-lint" , "create" , "--content" , valid_gitlab_ci_yml ]
27
- ret = gitlab_cli (cmd )
28
-
29
- assert ret .success
30
-
31
-
32
- def test_validate_ci_lint (gitlab_cli , valid_gitlab_ci_yml ):
33
- cmd = ["ci-lint" , "validate" , "--content" , valid_gitlab_ci_yml ]
34
- ret = gitlab_cli (cmd )
35
-
36
- assert ret .success
37
-
38
-
39
- def test_validate_ci_lint_invalid_exits_non_zero (gitlab_cli , invalid_gitlab_ci_yml ):
40
- cmd = ["ci-lint" , "validate" , "--content" , invalid_gitlab_ci_yml ]
41
- ret = gitlab_cli (cmd )
42
-
43
- assert not ret .success
44
- assert "CI YAML Lint failed (Invalid configuration format)" in ret .stderr
45
-
46
-
47
29
def test_validate_project_ci_lint (gitlab_cli , project , valid_gitlab_ci_yml ):
48
30
cmd = [
49
31
"project-ci-lint" ,
@@ -103,7 +85,7 @@ def test_create_user(gitlab_cli, gl):
103
85
email = "fake@email.com"
104
86
username = "user1"
105
87
name = "User One"
106
- password = "fakepassword "
88
+ password = "E4596f8be406Bc3a14a4ccdb1df80587 "
107
89
108
90
cmd = [
109
91
"user" ,
@@ -215,8 +197,6 @@ def test_create_issue_note(gitlab_cli, issue):
215
197
216
198
217
199
def test_create_branch (gitlab_cli , project ):
218
- branch = "branch1"
219
-
220
200
cmd = [
221
201
"project-branch" ,
222
202
"create" ,
@@ -233,7 +213,6 @@ def test_create_branch(gitlab_cli, project):
233
213
234
214
235
215
def test_create_merge_request (gitlab_cli , project ):
236
- branch = "branch1"
237
216
238
217
cmd = [
239
218
"project-merge-request" ,
@@ -257,23 +236,43 @@ def test_accept_request_merge(gitlab_cli, project, wait_for_sidekiq):
257
236
mr = project .mergerequests .list ()[0 ]
258
237
file_data = {
259
238
"branch" : mr .source_branch ,
260
- "file_path" : "README2 " ,
239
+ "file_path" : "test-cli-v4.md " ,
261
240
"content" : "Content" ,
262
- "commit_message" : "Pre-merge commit " ,
241
+ "commit_message" : "chore: test-cli-v4 change " ,
263
242
}
264
243
project .files .create (file_data )
265
- time .sleep (2 )
244
+ time .sleep (30 )
266
245
wait_for_sidekiq (timeout = 60 )
267
246
268
- cmd = [
247
+ logging .info (f"MR status: { mr .state } " )
248
+ logging .info (f"MR merge status: { mr .detailed_merge_status } " )
249
+
250
+ if mr .detailed_merge_status == "not_approved" :
251
+ logging .info ("Approving Merge Request" )
252
+
253
+ approve_cmd = [
254
+ "project-merge-request" ,
255
+ "approve" ,
256
+ "--project-id" ,
257
+ project .id ,
258
+ "--iid" ,
259
+ mr .iid ,
260
+ ]
261
+ gitlab_cli (approve_cmd )
262
+
263
+ time .sleep (5 )
264
+ logging .info (f"MR merge status: { mr .detailed_merge_status } " )
265
+
266
+ time .sleep (0.5 )
267
+ approve_cmd = [
269
268
"project-merge-request" ,
270
269
"merge" ,
271
270
"--project-id" ,
272
271
project .id ,
273
272
"--iid" ,
274
273
mr .iid ,
275
274
]
276
- ret = gitlab_cli (cmd )
275
+ ret = gitlab_cli (approve_cmd )
277
276
278
277
assert ret .success
279
278
@@ -501,9 +500,6 @@ def test_delete_project_variable(gitlab_cli, variable):
501
500
502
501
503
502
def test_delete_branch (gitlab_cli , project ):
504
- # TODO: branch fixture
505
- branch = "branch1"
506
-
507
503
cmd = ["project-branch" , "delete" , "--project-id" , project .id , "--name" , branch ]
508
504
ret = gitlab_cli (cmd )
509
505
@@ -590,7 +586,7 @@ def test_create_project_with_values_at_prefixed(gitlab_cli, tmpdir):
590
586
def test_create_project_deploy_token (gitlab_cli , project ):
591
587
name = "project-token"
592
588
username = "root"
593
- expires_at = "2021-09-09"
589
+ expires_at = date . today (). isoformat ()
594
590
scopes = "read_registry"
595
591
596
592
cmd = [
@@ -666,7 +662,7 @@ def test_delete_project_deploy_token(gitlab_cli, deploy_token):
666
662
def test_create_group_deploy_token (gitlab_cli , group ):
667
663
name = "group-token"
668
664
username = "root"
669
- expires_at = "2021-09-09"
665
+ expires_at = date . today (). isoformat ()
670
666
scopes = "read_registry"
671
667
672
668
cmd = [
0 commit comments