1+ import logging
12import os
23import time
4+ from datetime import date
5+
6+ branch = "branch-cli-v4"
37
48
59def test_create_project (gitlab_cli ):
@@ -22,28 +26,6 @@ def test_update_project(gitlab_cli, project):
2226 assert description in ret .stdout
2327
2428
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-
4729def test_validate_project_ci_lint (gitlab_cli , project , valid_gitlab_ci_yml ):
4830 cmd = [
4931 "project-ci-lint" ,
@@ -103,7 +85,7 @@ def test_create_user(gitlab_cli, gl):
10385 email = "fake@email.com"
10486 username = "user1"
10587 name = "User One"
106- password = "fakepassword "
88+ password = "E4596f8be406Bc3a14a4ccdb1df80587 "
10789
10890 cmd = [
10991 "user" ,
@@ -215,8 +197,6 @@ def test_create_issue_note(gitlab_cli, issue):
215197
216198
217199def test_create_branch (gitlab_cli , project ):
218- branch = "branch1"
219-
220200 cmd = [
221201 "project-branch" ,
222202 "create" ,
@@ -233,7 +213,6 @@ def test_create_branch(gitlab_cli, project):
233213
234214
235215def test_create_merge_request (gitlab_cli , project ):
236- branch = "branch1"
237216
238217 cmd = [
239218 "project-merge-request" ,
@@ -257,23 +236,43 @@ def test_accept_request_merge(gitlab_cli, project, wait_for_sidekiq):
257236 mr = project .mergerequests .list ()[0 ]
258237 file_data = {
259238 "branch" : mr .source_branch ,
260- "file_path" : "README2 " ,
239+ "file_path" : "test-cli-v4.md " ,
261240 "content" : "Content" ,
262- "commit_message" : "Pre-merge commit " ,
241+ "commit_message" : "chore: test-cli-v4 change " ,
263242 }
264243 project .files .create (file_data )
265- time .sleep (2 )
244+ time .sleep (30 )
266245 wait_for_sidekiq (timeout = 60 )
267246
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 = [
269268 "project-merge-request" ,
270269 "merge" ,
271270 "--project-id" ,
272271 project .id ,
273272 "--iid" ,
274273 mr .iid ,
275274 ]
276- ret = gitlab_cli (cmd )
275+ ret = gitlab_cli (approve_cmd )
277276
278277 assert ret .success
279278
@@ -501,9 +500,6 @@ def test_delete_project_variable(gitlab_cli, variable):
501500
502501
503502def test_delete_branch (gitlab_cli , project ):
504- # TODO: branch fixture
505- branch = "branch1"
506-
507503 cmd = ["project-branch" , "delete" , "--project-id" , project .id , "--name" , branch ]
508504 ret = gitlab_cli (cmd )
509505
@@ -590,7 +586,7 @@ def test_create_project_with_values_at_prefixed(gitlab_cli, tmpdir):
590586def test_create_project_deploy_token (gitlab_cli , project ):
591587 name = "project-token"
592588 username = "root"
593- expires_at = "2021-09-09"
589+ expires_at = date . today (). isoformat ()
594590 scopes = "read_registry"
595591
596592 cmd = [
@@ -666,7 +662,7 @@ def test_delete_project_deploy_token(gitlab_cli, deploy_token):
666662def test_create_group_deploy_token (gitlab_cli , group ):
667663 name = "group-token"
668664 username = "root"
669- expires_at = "2021-09-09"
665+ expires_at = date . today (). isoformat ()
670666 scopes = "read_registry"
671667
672668 cmd = [
0 commit comments