Example #1
0
 async def test_post_item(self):
     api_res = {"_type" : "Tik::Model::Event", "local_id":"xyz"}
     self.client._post =  asynctest.CoroutineMock(return_value=api_res)
     post = MagicMock()
     post.images = []
     post.content = "Test"
     resp = await self.client.post_item(post)
     assert resp == api_res
Example #2
0
 async def test_update_item_failin(self):
     self.client.get_id_at_target = lambda x: None
     post = MagicMock()
     post.images = []
     post.content = "Test, mit Ü."
     post.target_doc = {"ts": 456}
     res = await self.client.update_item(post)
     assert res == False
Example #3
0
    async def test_post_item(self):
        api_res = {"ok": True, "channel":"ABCDEFG","ts":"1466511630.000011",
                   "message":{
                        "text":"foobaz", "username":"******",
                        "bot_id":"ABCDEFG", "type":"message",
                        "subtype":"bot_message","ts":"1466511630.000011"}}
        self.client._post =  asynctest.CoroutineMock(return_value=api_res)

        post = MagicMock()
        post.images = []
        post.content = "Test, mit Ü."
        resp = await self.client.post_item(post)
        assert resp == api_res
Example #4
0
    async def test_update_item(self):
        api_res = {"ok": True, "channel":"ABCDEFG","ts":"1466511630.000011",
                   "message":{
                        "text":"foobaz", "username":"******",
                        "bot_id":"ABCDEFG", "type":"message",
                        "subtype":"bot_message","ts":"1466511630.000011"}}
        self.client._post =  asynctest.CoroutineMock(return_value=api_res)

        post = MagicMock()
        post.images = []
        post.content = "Test, mit Ü."
        post.target_doc = {"ts": 456}
        resp = await self.client.update_item(post)
        assert resp == api_res
        assert self.client._post.call_args == asynctest.call('https://slack.com/api/chat.update',
                             [('token', 'baz'), ('channel', None), ('text', 'Test, mit Ü.'), ('ts', 456)])