From 257e8c2fe0d5eb41f0c215e32063ae4974bf8644 Mon Sep 17 00:00:00 2001 From: gizmo385 Date: Mon, 1 Jul 2024 04:25:52 +0000 Subject: [PATCH] Remove some test code used during PR lib iteration --- lazy_github/lib/github/pull_requests.py | 66 ------------------------- 1 file changed, 66 deletions(-) diff --git a/lazy_github/lib/github/pull_requests.py b/lazy_github/lib/github/pull_requests.py index eebf36f..cc8bc18 100644 --- a/lazy_github/lib/github/pull_requests.py +++ b/lazy_github/lib/github/pull_requests.py @@ -105,69 +105,3 @@ def reconstruct_review_conversation_hierarchy(reviews: list[Review]) -> dict[int comment_nodes_by_review_id[in_reply_to_id].children.append(review_node) return {r.comment.id: r for r in comment_nodes_by_review_id.values() if r.comment.in_reply_to_id is None} - - -# Test code for validating that the PR review conversation logic is setup correctly -def _write_thread(thread_root: ReviewCommentNode, depth: int) -> None: - """ - A helper function for traversing the tree structure of a review commeent node and printing it out with relative - depth respected - """ - tabs = "\t" * depth - comment = thread_root.comment - body = comment.body[:80] - comment_time = comment.created_at.strftime("%x at %X") - if comment.user: - print(f"{tabs}{comment.user.login} @ {comment_time}: {body}") - else: - print(f"{tabs}Unknown @ {comment_time}: {body}") - for child in thread_root.children: - _write_thread(child, depth + 1) - - -async def _main() -> None: - client = GithubClient(Config.load_config(), token()) - user = await client.user() - repo = Repository( - name="discord.clj", - full_name="gizmo385/discord.clj", - default_branch="main", - private=False, - archived=False, - owner=user, - ) - pr = PartialPullRequest( - id=2, - number=4, - comments=5, - state=IssueState.CLOSED, - title="wat", - body="", - user=user, - created_at=datetime.now(), - updated_at=datetime.now(), - comments_url="", - draft=False, - locked=False, - assignee=None, - assignees=None, - repo=repo, - ) - full_pr = await get_full_pull_request(client, pr) - reviews = await get_reviews(client, full_pr) - hierarchy = reconstruct_review_conversation_hierarchy(reviews) - - # For each of the reviews, if their comments aren't root comments, we only build out threads for reviews whose - # comments are root comments. - for review in reviews: - if review.body: - print(f"{review.state.title()}: {review.body[:80]}") - for comment in review.comments: - if comment.id in hierarchy: - _write_thread(hierarchy[comment.id], 1) - - -if __name__ == "__main__": - import asyncio - - asyncio.run(_main())