diff options
author | Michael P. Soulier <msoulier@digitaltorque.ca> | 2012-09-30 22:07:20 -0400 |
---|---|---|
committer | Michael P. Soulier <msoulier@digitaltorque.ca> | 2012-09-30 22:07:20 -0400 |
commit | b57e583798be5e145f21ad0caf1c5d18f485df2a (patch) | |
tree | 61b3389e95aee9b4bd3eeb9bf69a39e0334ee69a /t | |
parent | 792e849d20a3598943ed6db9ddacf4db8e9bac49 (diff) | |
download | tftpy-b57e583798be5e145f21ad0caf1c5d18f485df2a.tar.gz |
Adding testcases for new file-like input and output
Diffstat (limited to 't')
-rw-r--r-- | t/test.py | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -141,12 +141,14 @@ class TestTftpyState(unittest.TestCase): def setUp(self): tftpy.setLogLevel(logging.DEBUG) - def clientServerUploadOptions(self, options, transmitname=None): + def clientServerUploadOptions(self, options, input=None, transmitname=None): """Fire up a client and a server and do an upload.""" root = '/tmp' home = os.path.dirname(os.path.abspath(__file__)) filename = '100KBFILE' input_path = os.path.join(home, filename) + if not input: + input = input_path if transmitname: filename = transmitname server = tftpy.TftpServer(root) @@ -160,7 +162,7 @@ class TestTftpyState(unittest.TestCase): try: time.sleep(1) client.upload(filename, - input_path) + input) finally: os.kill(child_pid, 15) os.waitpid(child_pid, 0) @@ -168,7 +170,7 @@ class TestTftpyState(unittest.TestCase): else: server.listen('localhost', 20001) - def clientServerDownloadOptions(self, options): + def clientServerDownloadOptions(self, options, output='/tmp/out'): """Fire up a client and a server and do a download.""" root = os.path.dirname(os.path.abspath(__file__)) server = tftpy.TftpServer(root) @@ -182,7 +184,7 @@ class TestTftpyState(unittest.TestCase): try: time.sleep(1) client.download('100KBFILE', - '/tmp/out') + output) finally: os.kill(child_pid, 15) os.waitpid(child_pid, 0) @@ -193,6 +195,10 @@ class TestTftpyState(unittest.TestCase): def testClientServerNoOptions(self): self.clientServerDownloadOptions({}) + def testClientFileObject(self): + output = open('/tmp/out', 'w') + self.clientServerDownloadOptions({}, output) + def testClientServerBlksize(self): for blksize in [512, 1024, 2048, 4096]: self.clientServerDownloadOptions({'blksize': blksize}) @@ -200,6 +206,10 @@ class TestTftpyState(unittest.TestCase): def testClientServerUploadNoOptions(self): self.clientServerUploadOptions({}) + def testClientServerUploadFileObj(self): + fileobj = open('/tmp/100KBFILE', 'r') + self.clientServerUploadOptions({}, input=fileobj) + def testClientServerUploadWithSubdirs(self): self.clientServerUploadOptions({}, transmitname='foo/bar/100KBFILE') |