mirror of
https://github.com/haiwen/libsearpc.git
synced 2025-09-13 21:41:09 +00:00
Added failing tests for named pipe
This commit is contained in:
@@ -14,6 +14,6 @@ script:
|
||||
- ./configure
|
||||
- make -j4
|
||||
- make check -j4
|
||||
- cd pysearpc && python test_pysearpc.py
|
||||
- python pysearpc/test_pysearpc.py
|
||||
notifications:
|
||||
email: false
|
||||
|
@@ -1,4 +1,4 @@
|
||||
from .common import SearpcError
|
||||
from .client import SearpcClient, searpc_func, SearpcObjEncoder
|
||||
from .server import searpc_server
|
||||
from .transport import SearpcTransport
|
||||
from .transport import SearpcTransport, NamedPipeTransport
|
||||
|
@@ -2,24 +2,23 @@
|
||||
#coding: UTF-8
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from operator import add
|
||||
from operator import add, mul
|
||||
|
||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, '..')
|
||||
from pysearpc import (
|
||||
SearpcClient, SearpcError, SearpcTransport, searpc_func, searpc_server
|
||||
SearpcClient, SearpcError, SearpcTransport, searpc_func, searpc_server, NamedPipeTransport
|
||||
)
|
||||
|
||||
SVCNAME = 'test-service'
|
||||
|
||||
def multi(a, b):
|
||||
return a * b
|
||||
|
||||
def init_server():
|
||||
searpc_server.create_service(SVCNAME)
|
||||
searpc_server.register_function(SVCNAME, add, 'add')
|
||||
searpc_server.register_function(SVCNAME, multi, 'multi')
|
||||
searpc_server.register_function(SVCNAME, mul, 'multi')
|
||||
|
||||
|
||||
class DummyTransport(SearpcTransport):
|
||||
@@ -39,14 +38,32 @@ class SampleRpcClient(SearpcClient):
|
||||
def add(self, x, y):
|
||||
pass
|
||||
|
||||
@searpc_func("string", ["string", "int"])
|
||||
def multi(self, x, y):
|
||||
pass
|
||||
|
||||
class SearpcTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
init_server()
|
||||
self.client = SampleRpcClient()
|
||||
|
||||
def testNormalTransport(self):
|
||||
def test_normal_transport(self):
|
||||
self.run_common()
|
||||
|
||||
@unittest.skip('not implemented yet')
|
||||
def test_pipe_transport(self):
|
||||
self.client.transport = NamedPipeTransport('/tmp/libsearpc-test.sock')
|
||||
self.run_common()
|
||||
|
||||
def run_common(self):
|
||||
v = self.client.add(1, 2)
|
||||
self.assertEqual(v, 3)
|
||||
|
||||
v = self.client.multi(1, 2)
|
||||
self.assertEqual(v, 2)
|
||||
|
||||
v = self.client.multi('abc', 2)
|
||||
self.assertEqual(v, 'abcabc')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@@ -6,3 +6,11 @@ class SearpcTransport(object):
|
||||
"""
|
||||
def send(self, request_str):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class NamedPipeTransport(SearpcTransport):
|
||||
def __init__(self, pipe_path):
|
||||
self.pipe_path = pipe_path
|
||||
|
||||
def send(self, fcall_str):
|
||||
pass
|
||||
|
Reference in New Issue
Block a user