Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_same_group_id(self):
group = groups.Group(mock.Mock(), **get_fake_group_data())
self.assertEqual(self.group, group)
def test_result_is_group(self):
self.assertTrue(isinstance(self.result, groups.Group))
def test_different_group_id(self):
group = groups.Group(mock.Mock(), **get_fake_group_data())
group.group_id = 2 * self.group.group_id
self.assertNotEqual(self.group, group)
def join(self, group_id, share_token):
"""Join a group using a share token.
:param str group_id: the group_id of a group
:param str share_token: the share token
:return: the group
:rtype: :class:`~groupy.api.groups.Group`
"""
path = '{}/join/{}'.format(group_id, share_token)
url = utils.urljoin(self.url, path)
response = self.session.post(url)
group = response.data['group']
return Group(self, **group)
def get(self, id):
"""Get a single group by ID.
:param str id: a group ID
:return: a group
:rtype: :class:`~groupy.api.groups.Group`
"""
url = utils.urljoin(self.url, id)
response = self.session.get(url)
return Group(self, **response.data)
:param str name: group name (140 characters maximum)
:param str description: short description (255 characters maximum)
:param str image_url: GroupMe image service URL
:param bool share: whether to generate a share URL
:return: a new group
:rtype: :class:`~groupy.api.groups.Group`
"""
payload = {
'name': name,
'description': description,
'image_url': image_url,
'share': share,
}
payload.update(kwargs)
response = self.session.post(self.url, json=payload)
return Group(self, **response.data)
def rejoin(self, group_id):
"""Rejoin a former group.
:param str group_id: the group_id of a group
:return: the group
:rtype: :class:`~groupy.api.groups.Group`
"""
url = utils.urljoin(self.url, 'join')
payload = {'group_id': group_id}
response = self.session.post(url, json=payload)
return Group(self, **response.data)
def list_former(self):
"""List all former groups.
:return: a list of groups
:rtype: :class:`list`
"""
url = utils.urljoin(self.url, 'former')
response = self.session.get(url)
return [Group(self, **group) for group in response.data]
def _raw_list(self, **params):
response = self.session.get(self.url, params=params)
if response.status_code == 304:
return []
return [Group(self, **group) for group in response.data]
:param bool share: whether to generate a share URL
:return: an updated group
:rtype: :class:`~groupy.api.groups.Group`
"""
path = '{}/update'.format(id)
url = utils.urljoin(self.url, path)
payload = {
'name': name,
'description': description,
'image_url': image_url,
'office_mode': office_mode,
'share': share,
}
payload.update(kwargs)
response = self.session.post(url, json=payload)
return Group(self, **response.data)