diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/rest/members.py | 21 | ||||
| -rw-r--r-- | src/mailman/rest/tests/test_membership.py | 8 |
2 files changed, 15 insertions, 14 deletions
diff --git a/src/mailman/rest/members.py b/src/mailman/rest/members.py index 64e5ba23f..bb0c8b834 100644 --- a/src/mailman/rest/members.py +++ b/src/mailman/rest/members.py @@ -107,21 +107,22 @@ class MemberCollection(_MemberBase): class AMember(_MemberBase): """A member.""" - def __init__(self, api, member_or_id_string): - # The member_or_id_string is either the member's UUID or the string - # representation of the member's UUID. For the latter, in API 3.0, - # the argument is the string representation of the int representation - # of the UUID. In API 3.1 it's the hex. + def __init__(self, api, member_id): + # The member_id is either the member's UUID or the string + # representation of the member's UUID. self.api = api - if isinstance(member_or_id_string, UUID): - member_id = member_or_id_string + self._member = None + service = getUtility(ISubscriptionService) + if isinstance(member_id, UUID): + self._member = service.get_member(member_id) else: try: - member_id = api.to_uuid(member_or_id_string) + member_id = api.to_uuid(member_id) except ValueError: # The string argument could not be converted to a UUID. - self._member = None - self._member = getUtility(ISubscriptionService).get_member(member_id) + pass + else: + self._member = service.get_member(member_id) def on_get(self, request, response): """Return a single member end-point.""" diff --git a/src/mailman/rest/tests/test_membership.py b/src/mailman/rest/tests/test_membership.py index d69fedb35..6df10fbd1 100644 --- a/src/mailman/rest/tests/test_membership.py +++ b/src/mailman/rest/tests/test_membership.py @@ -522,10 +522,10 @@ class TestAPI31Members(unittest.TestCase): with transaction(): subscribe(self._mlist, 'Anne', email="aperson@example.com") response, headers = call_api( - 'http://localhost:9001/3.1/lists/ant.example.com/member/aperson@example.com') - self.assertEqual( - response['member_id'], - '00000000000000000000000000000001') + 'http://localhost:9001/3.1/lists/ant.example.com/member' + '/aperson@example.com') + self.assertEqual(response['member_id'], + '00000000000000000000000000000001') self.assertEqual( response['self_link'], 'http://localhost:9001/3.1/members/00000000000000000000000000000001') |
