Skip to content

Commit

Permalink
Merge branch 'main' into remove-pull-request-trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
cgundy authored Oct 30, 2023
2 parents 6bc9c2e + 26683c9 commit 013bc07
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
7 changes: 2 additions & 5 deletions reusable_workflows/check_membership/check_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ def main() -> None:
gh = github3.login(token=gh_token)

if not gh:
# Todo: change to Exception once GH_TOKEN can be passed in from forked repositories
print("github login failed - maybe GH_TOKEN was not correctly set")
is_member = False
raise Exception("github login failed - maybe GH_TOKEN was not correctly set")

else:
is_member = is_member_of_org(gh, org, user)
is_member = is_member_of_org(gh, org, user)

if is_member:
print(f"{user} is member of {org} and can contribute.")
Expand Down
21 changes: 7 additions & 14 deletions reusable_workflows/tests/test_membership.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,16 @@ def test_end_to_end_api_fails(os_system, github_login_mock):
os_system.assert_not_called()


@mock.patch.dict(os.environ, {"GH_ORG": "my_org", "GH_TOKEN": "", "USER": "username"})
@mock.patch.dict(
os.environ, {"GH_ORG": "my_org", "GH_TOKEN": "", "USER": "username"}
)
@mock.patch("github3.login")
def test_github_token_not_passed_in(github_login_mock, capfd):
def test_github_token_not_passed_in(github_login_mock):
github_login_mock.return_value = None

main()
out, err = capfd.readouterr()
with pytest.raises(Exception) as exc:
main()

assert (
out
== "github login failed - maybe GH_TOKEN was not correctly set\nusername is an external contributor.\n"
str(exc.value) == "github login failed - maybe GH_TOKEN was not correctly set"
)

# Todo: switch back once exception is added back
# with pytest.raises(Exception) as exc:
# main()

# assert (
# str(exc.value) == "github login failed - maybe GH_TOKEN was not correctly set"
# )
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ ignore_missing_imports = True
ignore_missing_imports = True

[flake8]
ignore = E501, W503
ignore = E501

0 comments on commit 013bc07

Please sign in to comment.