def test_transfer_with_cli(self):
test_instances = [
TestUrlInstance(url="/data1", data=b"data1"),
TestUrlInstance(url="/data2", data=b"data2")
]
self.httpd.test_instances = test_instances
try:
fd, filename = tempfile.mkstemp()
os.close(fd)
cmd = [TestRequestHandler.ticket_url, "-O", filename]
parser = cli.get_htsget_parser()
args = parser.parse_args(cmd)
with mock.patch("sys.exit") as mocked_exit:
cli.run(args)
mocked_exit.assert_called_once_with(0)
all_data = b"".join(test_instance.data for test_instance in test_instances)
with open(filename, "rb") as f:
self.assertEqual(f.read(), all_data)
finally:
os.unlink(filename)
评论列表
文章目录