Skip to content

Commit

Permalink
Fix sync pytests
Browse files Browse the repository at this point in the history
  • Loading branch information
ewels committed Mar 30, 2022
1 parent 289231a commit 84b637f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nf_core/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def make_pull_request(self):
return_retry=[403],
)
except Exception as e:
stderr.print_exception(e)
stderr.print_exception()
raise PullRequestException(f"Something went badly wrong - {e}")
else:
self.gh_pr_returned_data = r.json()
Expand Down
4 changes: 2 additions & 2 deletions nf_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ def __call__(self, r):
while True:
# GET request
if post_data is None:
r = requests.get(url, auth=auth)
r = requests.get(url=url, auth=auth)
# POST request
else:
r = requests.post(url, json=post_data, auth=auth)
r = requests.post(url=url, json=post_data, auth=auth)

try:
r_headers_pp = json.dumps(dict(r.headers), indent=4)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ def __init__(self, data, status_code):
self.content = json.dumps(data)
self.headers = {"content-encoding": "test", "connection": "fake"}

def json(self):
return json.loads(self.content)

if kwargs["url"] == "https://api.github.com/repos/no_existing_pr/response/pulls":
response_data = {"html_url": "great_success"}
return MockResponse(response_data, 201)
Expand Down Expand Up @@ -229,4 +232,4 @@ def test_make_pull_request_bad_response(self, mock_get, mock_post):
psync.make_pull_request()
raise UserWarning("Should have hit an exception")
except nf_core.sync.PullRequestException as e:
assert e.args[0].startswith("GitHub API returned code 404:")
assert e.args[0].startswith("Something went badly wrong - GitHub API PR failed - got return code 404")

0 comments on commit 84b637f

Please sign in to comment.