Skip to content

Commit

Permalink
Remove some test code used during PR lib iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmo385 committed Jul 1, 2024
1 parent 9274270 commit 257e8c2
Showing 1 changed file with 0 additions and 66 deletions.
66 changes: 0 additions & 66 deletions lazy_github/lib/github/pull_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

0 comments on commit 257e8c2

Please sign in to comment.