dbt-selly/dbt-env/lib/python3.8/site-packages/jsonrpc/tests/test_base.py

40 lines
936 B
Python
Raw Normal View History

2022-03-22 15:13:27 +00:00
""" Test base JSON-RPC classes."""
import sys
from ..base import JSONRPCBaseRequest, JSONRPCBaseResponse
if sys.version_info < (2, 7):
import unittest2 as unittest
else:
import unittest
class TestJSONRPCBaseRequest(unittest.TestCase):
""" Test JSONRPCBaseRequest functionality."""
def test_data(self):
request = JSONRPCBaseRequest()
self.assertEqual(request.data, {})
with self.assertRaises(ValueError):
request.data = []
with self.assertRaises(ValueError):
request.data = None
class TestJSONRPCBaseResponse(unittest.TestCase):
""" Test JSONRPCBaseResponse functionality."""
def test_data(self):
response = JSONRPCBaseResponse(result="")
self.assertEqual(response.data, {})
with self.assertRaises(ValueError):
response.data = []
with self.assertRaises(ValueError):
response.data = None