Skip to content

Instantly share code, notes, and snippets.

@TTimo
Created June 24, 2013 20:34
Show Gist options
  • Save TTimo/5853386 to your computer and use it in GitHub Desktop.
Save TTimo/5853386 to your computer and use it in GitHub Desktop.
# -*- Mode: python -*-
import pprint
from twisted.trial import unittest
from twisted.internet import reactor, protocol
import server
class ConnectClient( protocol.DatagramProtocol ):
def connect_to( self, address ):
self.transport.write( 'foo', ( address.host, address.port ) )
reactor.callLater( 1, reactor.stop )
class TestPeerManagement( unittest.TestCase ):
def test_oneClient( self ):
peers = server.PeerManagement()
reactor.listenUDP( 0, peers )
address = peers.transport.getHost()
connect_client = ConnectClient()
reactor.listenUDP( 0, connect_client )
reactor.callWhenRunning( connect_client.connect_to, address )
reactor.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment