def test_group_membership(self): gws = GWS() members = gws.get_members('u_acadev_unittest') self.assertEquals(len(members), 2) self.assertIn(GroupMember(type="uwnetid", name="eight"), members) self.assertNotIn(GroupMember(type="eppn", name="*****@*****.**"), members)
def test_update_members(self, mock_put): gws = GWS() members = gws.get_members('u_acadev_unittest') self.assertEquals(len(members), 2) members.remove(GroupMember(type="uwnetid", name="eight")) res = gws.update_members('u_acadev_unittest', members) mock_put.assert_called_with( '/group_sws/v3/group/u_acadev_unittest/member', {'If-Match': '*'}, {'data': [{'type': 'uwnetid', 'id': 'javerage'}]}) members.append(GroupMember(type="uwnetid", name="seven")) members.append(GroupMember(type="uwnetid", name="eight")) members.append(GroupMember(type="uwnetid", name="nine")) res = gws.update_members('u_acadev_unittest', members) mock_put.assert_called_with( '/group_sws/v3/group/u_acadev_unittest/member', {'If-Match': '*'}, {'data': [{'type': 'uwnetid', 'id': 'javerage'}, {'type': 'uwnetid', 'id': 'seven'}, {'type': 'uwnetid', 'id': 'eight'}, {'type': 'uwnetid', 'id': 'nine'}]})
def get_members(group_id): settings_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'settings.cfg') use_configparser_backend(settings_path, 'GWS') from uw_gws import GWS client = GWS() for member in client.get_members(group_id): print(member.name)