MCPcopy Index your code
hub / github.com/googleapis/google-api-python-client / test_basic

Method test_basic

tests/test_channel.py:13–56  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

11
12class TestChannel(unittest.TestCase):
13 def test_basic(self):
14 ch = channel.Channel(
15 "web_hook",
16 "myid",
17 "mytoken",
18 "http://example.org/callback",
19 expiration=0,
20 params={"extra": "info"},
21 resource_id="the_resource_id",
22 resource_uri="http://example.com/resource_1",
23 )
24
25 # Converting to a body.
26 body = ch.body()
27 self.assertEqual("http://example.org/callback", body["address"])
28 self.assertEqual("myid", body["id"])
29 self.assertEqual("missing", body.get("expiration", "missing"))
30 self.assertEqual("info", body["params"]["extra"])
31 self.assertEqual("the_resource_id", body["resourceId"])
32 self.assertEqual("http://example.com/resource_1", body["resourceUri"])
33 self.assertEqual("web_hook", body["type"])
34
35 # Converting to a body with expiration set.
36 ch.expiration = 1
37 body = ch.body()
38 self.assertEqual(1, body.get("expiration", "missing"))
39
40 # Converting to a body after updating with a response body.
41 ch.update(
42 {
43 "resourceId": "updated_res_id",
44 "resourceUri": "updated_res_uri",
45 "some_random_parameter": 2,
46 }
47 )
48
49 body = ch.body()
50 self.assertEqual("http://example.org/callback", body["address"])
51 self.assertEqual("myid", body["id"])
52 self.assertEqual(1, body.get("expiration", "missing"))
53 self.assertEqual("info", body["params"]["extra"])
54 self.assertEqual("updated_res_id", body["resourceId"])
55 self.assertEqual("updated_res_uri", body["resourceUri"])
56 self.assertEqual("web_hook", body["type"])
57
58 def test_new_webhook_channel(self):
59 ch = channel.new_webhook_channel("http://example.com/callback")

Callers

nothing calls this directly

Calls 3

bodyMethod · 0.95
updateMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected