fix more tests (that examine internals)
This commit is contained in:
parent
7b91377e94
commit
ff578fccf8
|
@ -13,9 +13,11 @@ def handshake(token, side=None):
|
||||||
|
|
||||||
class _Transit:
|
class _Transit:
|
||||||
def count(self):
|
def count(self):
|
||||||
return sum([len(potentials)
|
return sum([
|
||||||
for potentials
|
len(potentials)
|
||||||
in self._transit_server._pending_requests.values()])
|
for potentials
|
||||||
|
in self._transit_server.pending_requests._requests.values()
|
||||||
|
])
|
||||||
|
|
||||||
def test_blur_size(self):
|
def test_blur_size(self):
|
||||||
blur = transit_server.blur_size
|
blur = transit_server.blur_size
|
||||||
|
@ -50,7 +52,7 @@ class _Transit:
|
||||||
self.assertEqual(self.count(), 0)
|
self.assertEqual(self.count(), 0)
|
||||||
|
|
||||||
# the token should be removed too
|
# the token should be removed too
|
||||||
self.assertEqual(len(self._transit_server._pending_requests), 0)
|
self.assertEqual(len(self._transit_server.pending_requests._requests), 0)
|
||||||
|
|
||||||
def test_both_unsided(self):
|
def test_both_unsided(self):
|
||||||
p1 = self.new_protocol()
|
p1 = self.new_protocol()
|
||||||
|
@ -186,8 +188,8 @@ class _Transit:
|
||||||
p3.send(handshake(token1, side=side2))
|
p3.send(handshake(token1, side=side2))
|
||||||
self.flush()
|
self.flush()
|
||||||
self.assertEqual(self.count(), 0)
|
self.assertEqual(self.count(), 0)
|
||||||
self.assertEqual(len(self._transit_server._pending_requests), 0)
|
self.assertEqual(len(self._transit_server.pending_requests._requests), 0)
|
||||||
self.assertEqual(len(self._transit_server._active_connections), 2)
|
self.assertEqual(len(self._transit_server.active_connections._connections), 2)
|
||||||
# That will trigger a disconnect on exactly one of (p1 or p2).
|
# That will trigger a disconnect on exactly one of (p1 or p2).
|
||||||
# The other connection should still be connected
|
# The other connection should still be connected
|
||||||
self.assertEqual(sum([int(t.connected) for t in [p1, p2]]), 1)
|
self.assertEqual(sum([int(t.connected) for t in [p1, p2]]), 1)
|
||||||
|
@ -441,7 +443,7 @@ class Usage(ServerBase, unittest.TestCase):
|
||||||
|
|
||||||
p2.send(handshake(token1, side=side2))
|
p2.send(handshake(token1, side=side2))
|
||||||
self.flush()
|
self.flush()
|
||||||
self.assertEqual(len(self._transit_server._pending_requests), 0)
|
self.assertEqual(len(self._transit_server.pending_requests._requests), 0)
|
||||||
self.assertEqual(len(self._usage), 2, self._usage)
|
self.assertEqual(len(self._usage), 2, self._usage)
|
||||||
self.assertEqual(self._usage[1]["mood"], "redundant")
|
self.assertEqual(self._usage[1]["mood"], "redundant")
|
||||||
|
|
||||||
|
|
|
@ -270,8 +270,8 @@ class Transit(protocol.ServerFactory):
|
||||||
self._db = get_db(usage_db)
|
self._db = get_db(usage_db)
|
||||||
self._rebooted = time.time()
|
self._rebooted = time.time()
|
||||||
# we don't track TransitConnections until they submit a token
|
# we don't track TransitConnections until they submit a token
|
||||||
self._pending_requests = defaultdict(set) # token -> set((side, TransitConnection))
|
## self._pending_requests = defaultdict(set) # token -> set((side, TransitConnection))
|
||||||
self._active_connections = set() # TransitConnection
|
## self._active_connections = set() # TransitConnection
|
||||||
|
|
||||||
def transitFinished(self, tc, token, side, description):
|
def transitFinished(self, tc, token, side, description):
|
||||||
if token in self._pending_requests:
|
if token in self._pending_requests:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user