test_transit_server: improve coverage
This commit is contained in:
parent
c270ad6e0b
commit
05ffcb2d55
|
@ -4,10 +4,17 @@ from twisted.internet.defer import inlineCallbacks
|
||||||
from ..transit_server import Transit
|
from ..transit_server import Transit
|
||||||
|
|
||||||
class ServerBase:
|
class ServerBase:
|
||||||
|
log_requests = False
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self._lp = None
|
self._lp = None
|
||||||
yield self._setup_relay()
|
if self.log_requests:
|
||||||
|
blur_usage = None
|
||||||
|
else:
|
||||||
|
blur_usage = 60.0
|
||||||
|
yield self._setup_relay(blur_usage=blur_usage)
|
||||||
|
self._transit_server._debug_log = self.log_requests
|
||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def _setup_relay(self, blur_usage=None, log_file=None, usage_db=None):
|
def _setup_relay(self, blur_usage=None, log_file=None, usage_db=None):
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Accumulator(protocol.Protocol):
|
||||||
self._wait.errback(RuntimeError("closed"))
|
self._wait.errback(RuntimeError("closed"))
|
||||||
self._disconnect.callback(None)
|
self._disconnect.callback(None)
|
||||||
|
|
||||||
class Transit(ServerBase, unittest.TestCase):
|
class _Transit:
|
||||||
def test_blur_size(self):
|
def test_blur_size(self):
|
||||||
blur = transit_server.blur_size
|
blur = transit_server.blur_size
|
||||||
self.failUnlessEqual(blur(0), 0)
|
self.failUnlessEqual(blur(0), 0)
|
||||||
|
@ -372,3 +372,9 @@ class Transit(ServerBase, unittest.TestCase):
|
||||||
self.assertEqual(a1.data, exp)
|
self.assertEqual(a1.data, exp)
|
||||||
|
|
||||||
a1.transport.loseConnection()
|
a1.transport.loseConnection()
|
||||||
|
|
||||||
|
class TransitWithLogs(_Transit, ServerBase, unittest.TestCase):
|
||||||
|
log_requests = True
|
||||||
|
|
||||||
|
class TransitWithoutLogs(_Transit, ServerBase, unittest.TestCase):
|
||||||
|
log_requests = False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user