Exemplo n.º 1
0
	def test_is_notification(self):
		"""Check notification validation"""

		r0 = {"jsonrpc": "2.0", "method": "subtract", "params": 123, "id": 1}
		r1 = {"jsonrpc": "2.0", "method": "update", "params": [1,2,3,4,5]}
		r2 = {"jsonrpc": "2.0", "method": "foobar"}

		self.assertFalse(message.jsonrpc_is_notification(r0))
		self.assertTrue(message.jsonrpc_is_notification(r1))
		self.assertTrue(message.jsonrpc_is_notification(r2))
Exemplo n.º 2
0
	def test_notification(self):
		"""Check notify creation"""

		a0 = {'jsonrpc': '2.0', 'method': 'foobar'}
		r0 = message.jsonrpc_notify("foobar", None)

		a1 = {'jsonrpc': '2.0', 'method': 'foobar', 'params': [1,2,3]}
		r1 = message.jsonrpc_notify("foobar", [1,2,3])

		a2 = {'jsonrpc': '2.0', 'method': 'foobar', 'params': 'ZZZ'}
		r2 = message.jsonrpc_notify("foobar", "ZZZ")

		self.assertTrue(message.jsonrpc_is_notification(r0))
		self.assertTrue(message.jsonrpc_is_notification(r1))
		self.assertTrue(message.jsonrpc_is_notification(r2))

		self.assertEqual(set(a0.keys()), set(r0.keys()))
		self.assertEqual(set(a1.keys()), set(r1.keys()))
		self.assertEqual(set(a2.keys()), set(r2.keys()))