def test_payload_with_none_values(self): e = SlackAction() for attr, value in ACTION_PAYLOAD.items(): setattr(e, attr, value) e.title = None e.pretext = None ex = getMultiAdapter((self.folder, e, DummyEvent(self.doc)), IExecutable) payload = ex.get_message_payload() attachment = payload["attachments"][0] fields = attachment["fields"] self.assertEqual(u"", attachment["title"]) self.assertEqual(2, len(fields)) self.assertEqual(u"A Document", fields[0]["value"])
def test_execute(self): e = SlackAction() for attr, value in ACTION_PAYLOAD.items(): setattr(e, attr, value) ex = getMultiAdapter((self.folder, e, DummyEvent(self.doc)), IExecutable) with RequestsMock.installed() as requests: payload = ex.get_payload() self.wait_for(ex.notify_slack(payload)) self.assertEqual(1, len(requests.posts)) post = requests.posts[0] self.assertEqual(ACTION_PAYLOAD['webhook_url'], post.get('url')) self.assertEqual(10, post.get('timeout')) self.assertTrue(post.get('verify')) self.assertTrue('text' in post.get('json')) self.assertTrue('attachments' in post.get('json'))
def test_payload(self): e = SlackAction() for attr, value in ACTION_PAYLOAD.items(): setattr(e, attr, value) ex = getMultiAdapter((self.folder, e, DummyEvent(self.doc)), IExecutable) payload = ex.get_message_payload() self.assertEqual(u'Hello word! Private', payload['text']) attachment = payload['attachments'][0] fields = attachment['fields'] self.assertEqual(u'Document with title A Document', attachment['title']) self.assertEqual(2, len(fields)) self.assertEqual(u'A Document', fields[0]['value'])
def test_payload(self): e = SlackAction() for attr, value in ACTION_PAYLOAD.items(): setattr(e, attr, value) ex = getMultiAdapter((self.folder, e, DummyEvent(self.doc)), IExecutable) payload = ex.get_message_payload() self.assertEqual(u"Hello word! Private", payload["text"]) attachment = payload["attachments"][0] fields = attachment["fields"] self.assertEqual(u"Document with title A Document", attachment["title"]) self.assertEqual(2, len(fields)) self.assertEqual(u"A Document", fields[0]["value"])
def test_invoke_edit_view(self): element = getUtility(IRuleAction, name='plone.actions.Slack') e = SlackAction() editview = getMultiAdapter((e, self.request), name=element.editview) self.assertTrue(isinstance(editview, SlackEditFormView))