Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
self.m_manager = mock.Mock()
data = base.get_fake_message_data()
self.message = messages.Message(self.m_manager, **data)
def _get_messages(self, path=None, **params):
url = utils.urljoin(self.url, path)
response = self.session.get(url, params=params)
messages = response.data['messages']
return [Message(self, **message) for message in messages]
:rtype: :class:`~groupy.api.messages.Message`
"""
message = {
'source_guid': source_guid or str(time.time()),
}
if text is not None:
message['text'] = text
if attachments is not None:
message['attachments'] = [a.to_json() for a in attachments]
payload = {'message': message}
response = self.session.post(self.url, json=payload)
message = response.data['message']
return Message(self, **message)
def _raw_list(self, **params):
response = self.session.get(self.url, params=params)
if response.status_code == 304:
return []
messages = response.data['messages']
return [Message(self, **message) for message in messages]