tests: internal changes
This commit is contained in:
		
							parent
							
								
									efc23bd078
								
							
						
					
					
						commit
						2e2b869ec2
					
				| 
						 | 
					@ -15,7 +15,7 @@ class ServerBase:
 | 
				
			||||||
                        "tcp:%s:interface=127.0.0.1" % transitport,
 | 
					                        "tcp:%s:interface=127.0.0.1" % transitport,
 | 
				
			||||||
                        __version__)
 | 
					                        __version__)
 | 
				
			||||||
        s.setServiceParent(self.sp)
 | 
					        s.setServiceParent(self.sp)
 | 
				
			||||||
        self._relay_server = s._rendezvous
 | 
					        self._rendezvous = s._rendezvous
 | 
				
			||||||
        self._transit_server = s._transit
 | 
					        self._transit_server = s._transit
 | 
				
			||||||
        self.relayurl = u"http://127.0.0.1:%d/wormhole-relay/" % relayport
 | 
					        self.relayurl = u"http://127.0.0.1:%d/wormhole-relay/" % relayport
 | 
				
			||||||
        self.transit = u"tcp:127.0.0.1:%d" % transitport
 | 
					        self.transit = u"tcp:127.0.0.1:%d" % transitport
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,14 +52,14 @@ class Channel(ServerBase, unittest.TestCase):
 | 
				
			||||||
        # deallocating one side is not enough to destroy the channel
 | 
					        # deallocating one side is not enough to destroy the channel
 | 
				
			||||||
        d.addCallback(lambda _: deferToThread(c2.deallocate))
 | 
					        d.addCallback(lambda _: deferToThread(c2.deallocate))
 | 
				
			||||||
        def _not_yet(_):
 | 
					        def _not_yet(_):
 | 
				
			||||||
            self._relay_server.prune()
 | 
					            self._rendezvous.prune()
 | 
				
			||||||
            self.failUnlessEqual(len(self._relay_server._apps), 1)
 | 
					            self.failUnlessEqual(len(self._rendezvous._apps), 1)
 | 
				
			||||||
        d.addCallback(_not_yet)
 | 
					        d.addCallback(_not_yet)
 | 
				
			||||||
        # but deallocating both will make the messages go away
 | 
					        # but deallocating both will make the messages go away
 | 
				
			||||||
        d.addCallback(lambda _: deferToThread(c1.deallocate, u"sad"))
 | 
					        d.addCallback(lambda _: deferToThread(c1.deallocate, u"sad"))
 | 
				
			||||||
        def _gone(_):
 | 
					        def _gone(_):
 | 
				
			||||||
            self._relay_server.prune()
 | 
					            self._rendezvous.prune()
 | 
				
			||||||
            self.failUnlessEqual(len(self._relay_server._apps), 0)
 | 
					            self.failUnlessEqual(len(self._rendezvous._apps), 0)
 | 
				
			||||||
        d.addCallback(_gone)
 | 
					        d.addCallback(_gone)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return d
 | 
					        return d
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,7 +53,7 @@ class Reachable(ServerBase, unittest.TestCase):
 | 
				
			||||||
def unjson(data):
 | 
					def unjson(data):
 | 
				
			||||||
    return json.loads(data.decode("utf-8"))
 | 
					    return json.loads(data.decode("utf-8"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class API(ServerBase, unittest.TestCase):
 | 
					class WebAPI(ServerBase, unittest.TestCase):
 | 
				
			||||||
    def build_url(self, path, appid, channelid):
 | 
					    def build_url(self, path, appid, channelid):
 | 
				
			||||||
        url = self.relayurl+path
 | 
					        url = self.relayurl+path
 | 
				
			||||||
        queryargs = []
 | 
					        queryargs = []
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,14 +51,14 @@ class Channel(ServerBase, unittest.TestCase):
 | 
				
			||||||
        # deallocating one side is not enough to destroy the channel
 | 
					        # deallocating one side is not enough to destroy the channel
 | 
				
			||||||
        d.addCallback(lambda _: c2.deallocate())
 | 
					        d.addCallback(lambda _: c2.deallocate())
 | 
				
			||||||
        def _not_yet(_):
 | 
					        def _not_yet(_):
 | 
				
			||||||
            self._relay_server.prune()
 | 
					            self._rendezvous.prune()
 | 
				
			||||||
            self.failUnlessEqual(len(self._relay_server._apps), 1)
 | 
					            self.failUnlessEqual(len(self._rendezvous._apps), 1)
 | 
				
			||||||
        d.addCallback(_not_yet)
 | 
					        d.addCallback(_not_yet)
 | 
				
			||||||
        # but deallocating both will make the messages go away
 | 
					        # but deallocating both will make the messages go away
 | 
				
			||||||
        d.addCallback(lambda _: c1.deallocate(u"sad"))
 | 
					        d.addCallback(lambda _: c1.deallocate(u"sad"))
 | 
				
			||||||
        def _gone(_):
 | 
					        def _gone(_):
 | 
				
			||||||
            self._relay_server.prune()
 | 
					            self._rendezvous.prune()
 | 
				
			||||||
            self.failUnlessEqual(len(self._relay_server._apps), 0)
 | 
					            self.failUnlessEqual(len(self._rendezvous._apps), 0)
 | 
				
			||||||
        d.addCallback(_gone)
 | 
					        d.addCallback(_gone)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        d.addCallback(lambda _: cm1.shutdown())
 | 
					        d.addCallback(lambda _: cm1.shutdown())
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user