Exemplo n.º 1
0
class PacketSendTest(unittest.TestCase):
    def setUp(self):
        self.host = Host()
        self.fd = MockFd()
        self.packet = MockPacket()

    def testSendPacket(self):
        self.host.SendPacket(self.fd, self.packet)
        self.failUnless(self.fd.data is self.packet.packet)
        self.failUnless(self.fd.target is self.packet.source)

    def testSendReplyPacket(self):
        self.host.SendReplyPacket(self.fd, self.packet)
        self.failUnless(self.fd.data is self.packet.replypacket)
        self.failUnless(self.fd.target is self.packet.source)
Exemplo n.º 2
0
class PacketCreationTests(unittest.TestCase):
    def setUp(self):
        self.host = Host()

    def testCreatePacket(self):
        packet = self.host.CreatePacket(id=15)
        self.failUnless(isinstance(packet, Packet))
        self.failUnless(packet.dict is self.host.dict)
        self.assertEqual(packet.id, 15)

    def testCreateAuthPacket(self):
        packet = self.host.CreateAuthPacket(id=15)
        self.failUnless(isinstance(packet, AuthPacket))
        self.failUnless(packet.dict is self.host.dict)
        self.assertEqual(packet.id, 15)

    def testCreateAcctPacket(self):
        packet = self.host.CreateAcctPacket(id=15)
        self.failUnless(isinstance(packet, AcctPacket))
        self.failUnless(packet.dict is self.host.dict)
        self.assertEqual(packet.id, 15)
Exemplo n.º 3
0
 def testSimpleConstruction(self):
     host = Host()
     self.assertEqual(host.authport, 1812)
     self.assertEqual(host.acctport, 1813)
Exemplo n.º 4
0
 def setUp(self):
     self.host = Host()
     self.fd = MockFd()
     self.packet = MockPacket()
Exemplo n.º 5
0
 def setUp(self):
     self.host = Host()
Exemplo n.º 6
0
 def testNamedParameters(self):
     host = Host(authport=123, acctport=456, coaport=789, dict=101)
     self.assertEqual(host.authport, 123)
     self.assertEqual(host.acctport, 456)
     self.assertEqual(host.coaport, 789)
     self.assertEqual(host.dict, 101)
Exemplo n.º 7
0
 def testParameterOrder(self):
     host = Host(123, 456, 789, 101)
     self.assertEqual(host.authport, 123)
     self.assertEqual(host.acctport, 456)
     self.assertEqual(host.coaport, 789)
     self.assertEqual(host.dict, 101)