Added testcase for TftpPacketFactory.

git-svn-id: https://tftpy.svn.sourceforge.net/svnroot/tftpy/trunk@29 63283fd4-ec1e-0410-9879-cb7f675518da
This commit is contained in:
msoulier 2006-10-25 01:41:03 +00:00
parent 7486502647
commit 8e6cd77aa7

View file

@ -116,6 +116,24 @@ class TestTftpy(unittest.TestCase):
self.assertEqual(oack.options['blksize'],
'4096',
"OACK blksize option is correct")
def testTftpPacketFactory(self):
log.debug("===> Running testcase testTftpPacketFactory")
# Make sure that the correct class is created for the correct opcode.
classes = {
1: tftpy.TftpPacketRRQ,
2: tftpy.TftpPacketWRQ,
3: tftpy.TftpPacketDAT,
4: tftpy.TftpPacketACK,
5: tftpy.TftpPacketERR,
6: tftpy.TftpPacketOACK
}
factory = tftpy.TftpPacketFactory()
for opcode in classes:
self.assert_(isinstance(factory.create(opcode),
classes[opcode]),
"opcode %d returns the correct class" % opcode)
if __name__ == '__main__':
unittest.main()