Skip to content

Commit cbcf411

Browse files
Refactor tests to use faker and reduce manual field setting
1 parent b299a1c commit cbcf411

File tree

2 files changed

+40
-145
lines changed

2 files changed

+40
-145
lines changed

tests/conftest.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,23 @@ def _create_event(event_type, delivery_id=None, **data):
277277
if event_type == "issue_comment" and "comment" not in data:
278278
data["comment"] = {"body": faker.sentence()}
279279

280-
if "comment" in data and isinstance(data["comment"], str):
281-
# Allow passing just the comment body as a string
282-
data["comment"] = {"body": data["comment"]}
283-
284280
if "comment" in data and "user" not in data["comment"]:
285281
data["comment"]["user"] = {"login": faker.user_name()}
286282

283+
if event_type == "issue_comment" and "issue" not in data:
284+
data["issue"] = {"number": faker.random_int(min=1, max=1000)}
285+
286+
if event_type == "commit_comment" and "commit" not in data:
287+
data["commit"] = {"sha": faker.sha1()}
288+
289+
if event_type == "pull_request_review_comment" and "pull_request" not in data:
290+
data["pull_request"] = {"number": faker.random_int(min=1, max=1000)}
291+
287292
if "repository" not in data and event_type in [
288293
"issue_comment",
289294
"pull_request",
295+
"pull_request_review_comment",
296+
"commit_comment",
290297
"push",
291298
]:
292299
data["repository"] = {

0 commit comments

Comments
 (0)