Created
June 24, 2013 20:34
-
-
Save TTimo/5853386 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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