예제 #1
0
 def test_user_agent_customization_issue_769(self):
     client = WebhookClient(
         url="http://localhost:8888/user-agent-this_is-test",
         user_agent_prefix="this_is",
         user_agent_suffix="test",
     )
     resp = client.send_dict({"text": "hi!"})
     self.assertEqual(resp.body, "ok")
예제 #2
0
 def test_proxy_issue_714(self):
     client = WebhookClient(
         url="http://localhost:8888", proxy="http://invalid-host:9999"
     )
     with self.assertRaises(urllib.error.URLError):
         client.send_dict({"text": "hello!"})
예제 #3
0
 def test_error_response(self):
     client = WebhookClient(url="http://localhost:8888/error")
     resp: WebhookResponse = client.send_dict({"text": "hello!"})
     self.assertEqual(500, resp.status_code)
     self.assertTrue(resp.body.startswith("<!DOCTYPE html>"))
예제 #4
0
 def test_timeout_issue_712(self):
     client = WebhookClient(url="http://localhost:8888/timeout", timeout=1)
     with self.assertRaises(socket.timeout):
         client.send_dict({"text": "hello!"})
예제 #5
0
 def test_send_dict(self):
     client = WebhookClient("http://localhost:8888")
     resp: WebhookResponse = client.send_dict({"text": "hello!"})
     self.assertEqual(200, resp.status_code)
     self.assertEqual("ok", resp.body)
예제 #6
0
 def test_error_response(self):
     client = WebhookClient(url="http://localhost:8888/error")
     resp: WebhookResponse = client.send_dict({"text": "hello!"})
     self.assertEqual(500, resp.status_code)
     self.assertEqual("error", resp.body)