diff --git a/allspice/apiobject.py b/allspice/apiobject.py index 8c8d3ef..a3d8534 100644 --- a/allspice/apiobject.py +++ b/allspice/apiobject.py @@ -2042,7 +2042,7 @@ class DesignReview(ApiObject): base: str body: str changed_files: int - closed_at: Any + closed_at: Optional[str] comments: int created_at: str deletions: int @@ -2055,11 +2055,11 @@ class DesignReview(ApiObject): is_locked: bool labels: List[Any] merge_base: str - merge_commit_sha: Any + merge_commit_sha: Optional[str] mergeable: bool merged: bool - merged_at: Any - merged_by: Any + merged_at: Optional[str] + merged_by: Optional["User"] milestone: Any number: int patch_url: str @@ -2165,7 +2165,7 @@ def merge(self, merge_type: MergeType): :param merge_type: The type of merge to perform. See the MergeType enum. """ - self.allspice_client.requests_put( + self.allspice_client.requests_post( self.MERGE_DESIGN_REVIEW.format( owner=self.repository.owner.username, repo=self.repository.name, diff --git a/tests/test_api.py b/tests/test_api.py index 7b3239e..59bdb76 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -674,6 +674,11 @@ def test_create_design_review(instance): org = Organization.request(instance, test_org) repo = Repository.request(instance, org.username, test_repo) branch = Branch.request(instance, org.username, test_repo, "master") + repo.create_file( + "new_file.txt", + base64.b64encode(b"new file contents").decode("utf-8"), + {"branch": "test_branch"}, + ) due_date = datetime.datetime.now() + datetime.timedelta(days=7) review = repo.create_design_review( "TestDesignReview", @@ -762,6 +767,33 @@ def test_get_design_review_attachments(instance): assert attachments[0].name == "requirements.txt" +def test_merge_design_review(instance): + org = Organization.request(instance, test_org) + repo = Repository.request(instance, org.username, test_repo) + dr = repo.get_design_reviews()[0] + + assert dr.state == "open" + + # The API may fail with this message. It isn't in the scope of this test to + # make sure the API can merge, so we'll keep retrying until it works or we + # retry too many times. + attempts = 0 + while attempts < 5: + try: + dr.merge(DesignReview.MergeType.MERGE) + break + except Exception as e: + if "Please try again later" in str(e): + attempts += 1 + time.sleep(1) + continue + else: + raise e + + dr = repo.get_design_reviews()[0] + assert dr.state == "closed" + + def test_repo_create_release(instance): org = Organization.request(instance, test_org) repo = Repository.request(instance, org.username, test_repo)