From 35479dcbd2ce38b1368817c00148fb31981069f0 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Thu, 18 Apr 2019 15:48:02 -0400 Subject: [PATCH] add file_save integration tests --- scripts/generate_json_api.py | 5 +++++ tests/integration/test_streaming.py | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/scripts/generate_json_api.py b/scripts/generate_json_api.py index c0308b7b3..c6a2f1573 100644 --- a/scripts/generate_json_api.py +++ b/scripts/generate_json_api.py @@ -325,6 +325,11 @@ class Examples(CommandTestCase): 'get', file_uri ) + await r( + 'Save a file to the downloads directory', + 'file', 'save', f"--sd_hash=\"{file_list_result[0]['sd_hash']}\"" + ) + # blobs bloblist = await r( diff --git a/tests/integration/test_streaming.py b/tests/integration/test_streaming.py index 2462b8271..b0f11f605 100644 --- a/tests/integration/test_streaming.py +++ b/tests/integration/test_streaming.py @@ -311,3 +311,24 @@ class RangeRequests(CommandTestCase): await self._test_range_requests() self.assertEqual(start_file_count, len(os.listdir(self.daemon.blob_manager.blob_dir))) self.assertEqual(blobs_in_stream, self.daemon.jsonrpc_file_list()[0].blobs_remaining) + + async def test_file_save_streaming_only_save_blobs(self): + await self.test_streaming_only_with_blobs() + stream = self.daemon.jsonrpc_file_list()[0] + self.assertIsNone(stream.full_path) + self.server.stop_server() + await self.daemon.jsonrpc_file_save('test', self.daemon.conf.data_dir) + stream = self.daemon.jsonrpc_file_list()[0] + await stream.finished_writing.wait() + with open(stream.full_path, 'rb') as f: + self.assertEqual(self.data, f.read()) + + async def test_file_save_streaming_only_dont_save_blobs(self): + await self.test_streaming_only_without_blobs() + stream = self.daemon.jsonrpc_file_list()[0] + self.assertIsNone(stream.full_path) + await self.daemon.jsonrpc_file_save('test', self.daemon.conf.data_dir) + stream = self.daemon.jsonrpc_file_list()[0] + await stream.finished_writing.wait() + with open(stream.full_path, 'rb') as f: + self.assertEqual(self.data, f.read())