|
| 1 | +importjson |
| 2 | +importtime |
| 3 | + |
| 4 | + |
1 | 5 | deftest_project_create_file(gitlab_cli,project): |
2 | 6 | file_path="README" |
3 | 7 | branch="main" |
@@ -45,6 +49,49 @@ def test_list_all_commits(gitlab_cli, project): |
45 | 49 | assertlen(ret_all.stdout)>len(ret.stdout) |
46 | 50 |
|
47 | 51 |
|
| 52 | +deftest_commit_merge_requests(gitlab_cli,project,merge_request,wait_for_sidekiq): |
| 53 | +"""This tests the `project-commit merge-requests` command and also tests |
| 54 | + that we can print the result using the `json` formatter""" |
| 55 | +# create and then merge a merge-request |
| 56 | +source_branch="test_commit_merge_requests" |
| 57 | +mr=merge_request(source_branch=source_branch) |
| 58 | +merge_result=mr.merge(should_remove_source_branch=True) |
| 59 | +result=wait_for_sidekiq(timeout=60) |
| 60 | +assertresultisTrue,"sidekiq process should have terminated but did not" |
| 61 | +# Wait until it is merged |
| 62 | +mr_iid=mr.iid |
| 63 | +for_inrange(60): |
| 64 | +mr=project.mergerequests.get(mr_iid) |
| 65 | +ifmr.merged_atisnotNone: |
| 66 | +break |
| 67 | +time.sleep(0.5) |
| 68 | +assertmr.merged_atisnotNone |
| 69 | +time.sleep(0.5) |
| 70 | +result=wait_for_sidekiq(timeout=60) |
| 71 | +assertresultisTrue,"sidekiq process should have terminated but did not" |
| 72 | + |
| 73 | +commit_sha=merge_result["sha"] |
| 74 | +cmd= [ |
| 75 | +"-o", |
| 76 | +"json", |
| 77 | +"project-commit", |
| 78 | +"merge-requests", |
| 79 | +"--project-id", |
| 80 | +project.id, |
| 81 | +"--id", |
| 82 | +commit_sha, |
| 83 | + ] |
| 84 | +ret=gitlab_cli(cmd) |
| 85 | +assertret.success |
| 86 | + |
| 87 | +json_list=json.loads(ret.stdout) |
| 88 | +assertisinstance(json_list,list) |
| 89 | +assertlen(json_list)==1 |
| 90 | +mr_dict=json_list[0] |
| 91 | +assertmr_dict["id"]==mr.id |
| 92 | +assertmr_dict["iid"]==mr.iid |
| 93 | + |
| 94 | + |
48 | 95 | deftest_revert_commit(gitlab_cli,project): |
49 | 96 | commit=project.commits.list()[0] |
50 | 97 |
|
|