mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-28 17:03:52 +08:00
Merge pyextra subtree
This commit is contained in:
34
pyextra/jsonrpc/tests/test_bug29.py
Normal file
34
pyextra/jsonrpc/tests/test_bug29.py
Normal file
@@ -0,0 +1,34 @@
|
||||
""" Exmples of usage with tests.
|
||||
|
||||
Tests in this file represent examples taken from JSON-RPC specification.
|
||||
http://www.jsonrpc.org/specification#examples
|
||||
|
||||
"""
|
||||
import sys
|
||||
import json
|
||||
|
||||
from ..manager import JSONRPCResponseManager
|
||||
|
||||
if sys.version_info < (2, 7):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
|
||||
|
||||
def isjsonequal(json1, json2):
|
||||
return json.loads(json1) == json.loads(json2)
|
||||
|
||||
|
||||
class TestJSONRPCExamples(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.dispatcher = {
|
||||
"return_none": lambda: None,
|
||||
}
|
||||
|
||||
def test_none_as_result(self):
|
||||
req = '{"jsonrpc": "2.0", "method": "return_none", "id": 0}'
|
||||
response = JSONRPCResponseManager.handle(req, self.dispatcher)
|
||||
self.assertTrue(isjsonequal(
|
||||
response.json,
|
||||
'{"jsonrpc": "2.0", "result": null, "id": 0}'
|
||||
))
|
||||
Reference in New Issue
Block a user