forked from Charcoal-SE/SmokeDetector
-
Notifications
You must be signed in to change notification settings - Fork 0
better chat reporting in merge_pull_request
Jeff Schaller edited this page Apr 27, 2024
·
9 revisions
Python's requests library has logic for "if not response" that returns "false" for all 4xx and 5xx HTTP codes, including 404.
The CI testing calls test_approve() which calls assert chatcommands.approve(8888, original_msg=msg) == "Cannot connect to GitHub API"
(for a non-existent PR), so the test/wrapper needs to be updated at the same time.
What does: m.setattr("requests.get", lambda *args, **kwargs: None)
do?
- looks like it's a python "do-nothing" command/function
look for / watch all the places that call approve(); seems to just be in gitmanager.py and test_chatcommands:
- assert chatcommands.approve(8888, original_msg=msg).startswith("You need blacklist manager privileges")
- assert chatcommands.approve(8888, original_msg=msg) == "Cannot connect to GitHub API"
- assert chatcommands.approve(2518, original_msg=msg)[:8] in {"PR #2518", "Cannot c"}
Test manually, somehow, with pytest and:
with monkeypatch.context() as m:
# Oh no GitHub is down
original_get = requests.get
m.setattr("requests.get", lambda *args, **kwargs: None)
assert chatcommands.approve(8888, original_msg=msg) == "Cannot connect to GitHub API"
m.setattr("requests.get", original_get)