diff options
author | Jim Rollenhagen <jim@jimrollenhagen.com> | 2019-09-26 09:43:27 -0400 |
---|---|---|
committer | Jim Rollenhagen <jim@jimrollenhagen.com> | 2019-09-26 09:43:27 -0400 |
commit | e9c6edfe510f4ed407f8d2d84b4b931a382b48b3 (patch) | |
tree | 94bbd6a34bcf09e99f7ae1be88b19960192d6adb /wsme/tests/test_protocols.py | |
parent | 1d73d6e50411ebc45fb96a6ed3c63ca91a500323 (diff) | |
download | wsme-master.tar.gz |
Diffstat (limited to 'wsme/tests/test_protocols.py')
-rw-r--r-- | wsme/tests/test_protocols.py | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/wsme/tests/test_protocols.py b/wsme/tests/test_protocols.py deleted file mode 100644 index f4b7270..0000000 --- a/wsme/tests/test_protocols.py +++ /dev/null @@ -1,70 +0,0 @@ -# encoding=utf8 - -import unittest - -from wsme import WSRoot -from wsme.protocol import getprotocol, CallContext, Protocol -import wsme.protocol - - -class DummyProtocol(Protocol): - name = 'dummy' - content_types = ['', None] - - def __init__(self): - self.hits = 0 - - def accept(self, req): - return True - - def iter_calls(self, req): - yield CallContext(req) - - def extract_path(self, context): - return ['touch'] - - def read_arguments(self, context): - self.lastreq = context.request - self.hits += 1 - return {} - - def encode_result(self, context, result): - return str(result) - - def encode_error(self, context, infos): - return str(infos) - - -def test_getprotocol(): - try: - getprotocol('invalid') - assert False, "ValueError was not raised" - except ValueError: - pass - - -class TestProtocols(unittest.TestCase): - def test_register_protocol(self): - wsme.protocol.register_protocol(DummyProtocol) - assert wsme.protocol.registered_protocols['dummy'] == DummyProtocol - - r = WSRoot() - assert len(r.protocols) == 0 - - r.addprotocol('dummy') - assert len(r.protocols) == 1 - assert r.protocols[0].__class__ == DummyProtocol - - r = WSRoot(['dummy']) - assert len(r.protocols) == 1 - assert r.protocols[0].__class__ == DummyProtocol - - def test_Protocol(self): - p = wsme.protocol.Protocol() - assert p.iter_calls(None) is None - assert p.extract_path(None) is None - assert p.read_arguments(None) is None - assert p.encode_result(None, None) is None - assert p.encode_sample_value(None, None) == ('none', 'N/A') - assert p.encode_sample_params(None) == ('none', 'N/A') - assert p.encode_sample_result(None, None) == ('none', 'N/A') |