You've already forked bthlabs-jsonrpc
Initial public releases
* `bthlabs-jsonrpc-aiohttp` v1.0.0 * `bthlabs-jsonrpc-core` v1.0.0 * `bthlabs-jsonrpc-django` v1.0.0
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from bthlabs_jsonrpc_core import exceptions
|
||||
|
||||
|
||||
def test_to_rpc():
|
||||
# Given
|
||||
exception = exceptions.BaseJSONRPCError(data='spam')
|
||||
exception.ERROR_CODE = -32604
|
||||
exception.ERROR_MESSAGE = 'Test error'
|
||||
|
||||
# When
|
||||
result = exception.to_rpc()
|
||||
|
||||
# Then
|
||||
assert result['code'] == exception.ERROR_CODE
|
||||
assert result['message'] == exception.ERROR_MESSAGE
|
||||
assert result['data'] == exception.data
|
||||
|
||||
|
||||
def test_to_rpc_without_data():
|
||||
# Given
|
||||
exception = exceptions.BaseJSONRPCError()
|
||||
exception.ERROR_CODE = -32604
|
||||
exception.ERROR_MESSAGE = 'Test error'
|
||||
|
||||
# When
|
||||
result = exception.to_rpc()
|
||||
|
||||
# Then
|
||||
assert result['code'] == exception.ERROR_CODE
|
||||
assert result['message'] == exception.ERROR_MESSAGE
|
||||
assert 'data' not in result
|
||||
Reference in New Issue
Block a user