-
Notifications
You must be signed in to change notification settings - Fork 406
Add support for filtering team/organization members by role #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Takes advantage of some of the improved organization permissions https://developer.github.com/changes/2015-06-24-api-enhancements-for-working-with-organization-permissions/
Could you add tests for this @mwielgoszewski ? |
@sigmavirus24 I'd be happy to, however I'm not sure where the best place to add them is. Some likely candidates are:
Would the test be best under integration or unit? I would need to mock the server-side reply which returns the users filtered based on their role. Where would that information reside? Another issue I had in my earlier pull request was filtering users with
To test the Any guidance you can provide would be appreciated. |
So if you look at #395 (which I consider to be easily one of the most complete pull requests I've received recently) you'll see that @antoine-g added both an integration test and a unit test. Since you're adding functionality to both the Team and Organization classes, you'll need to add at least one test to each of those files. If there are integration tests that require you to be an org owner (and you aren't already one) do something like:
|
:param int number: (optional), number of members to return. Default: | ||
-1 will return all available. | ||
:param str etag: (optional), ETag from a previous request to the same | ||
endpoint | ||
:returns: generator of :class:`User <github3.users.User>`\ s | ||
""" | ||
headers = {} | ||
params = {} | ||
if filter in set(["2fa_disabled", "all"]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize I didn't catch this on the last PR, but can we make these sets frozensets
on the class itself?
In other words, something like,
class Organization(...):
"""docstring"""
members_filters = frozenset(['2fa_disabled', 'all'])
members_roles = frozenset(['all', 'admin', 'member'])
And likewise for the Team class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a good idea. I will add and include within this PR along with tests.
@sigmavirus24 I've added the necessary unit tests, integration tests, and cassettes in 7d3254b. I think the |
@mwielgoszewski looks great! Could you just add 2 or 3 more unit tests to ensure that passing a bogus role/filter won't be passed through? E.g., tests like: def test_members_excludes_fake_roles(self):
i = self.instance.members(role='bogus-role-name')
self.get_next(i)
self.session.get.assert_called_once_with(
# ...
params={'per_page': 100},
# ...
) |
Okay, just added some tests to ensure that a bogus role/filter isn't included in the request made to the API. |
✨ 🍰 🎆 ✨ You're awesome @mwielgoszewski! |
Add support for filtering team/organization members by role
Takes advantage of some of the improved organization permissions. In particular:
Wasn't sure if this is something you want to add to github3.py yet, as these API calls are available in preview mode (requires submitting a custom HTTP Accept header).