fix mime_type for torrent on json encoder

This commit is contained in:
Victor Shyba 2022-10-27 20:34:33 -03:00
parent 77d2c81a30
commit 2bf0ca6441
2 changed files with 5 additions and 5 deletions

View file

@ -296,7 +296,7 @@ class JSONResponseEncoder(JSONEncoder):
'stream_name': None,
'suggested_file_name': None,
'sd_hash': None,
'mime_type': None,
'mime_type': managed_stream.mime_type,
'key': None,
'total_bytes_lower_bound': total_bytes_lower_bound,
'total_bytes': total_bytes,
@ -330,7 +330,6 @@ class JSONResponseEncoder(JSONEncoder):
'stream_name': managed_stream.stream_name,
'suggested_file_name': managed_stream.suggested_file_name,
'sd_hash': managed_stream.descriptor.sd_hash,
'mime_type': managed_stream.mime_type,
'key': managed_stream.descriptor.key,
'blobs_completed': managed_stream.blobs_completed,
'blobs_in_stream': managed_stream.blobs_in_stream,

View file

@ -82,9 +82,10 @@ class FileCommands(CommandTestCase):
# second call, see its there and move on
self.assertNotIn('error', await self.out(self.daemon.jsonrpc_get('torrent')))
self.assertItemCount(await self.daemon.jsonrpc_file_list(), 1)
file = (await self.daemon.jsonrpc_file_list())['items'][0]
self.assertEqual(btih, file.identifier)
self.assertAlmostEqual(time.time(), file.added_on, delta=2)
file = (await self.out(self.daemon.jsonrpc_file_list()))['items'][0]
self.assertEqual(btih, file['metadata']['source']['bt_infohash'])
self.assertAlmostEqual(time.time(), file['added_on'], delta=2)
self.assertEqual("application/octet-stream", file['mime_type'])
self.assertIn(btih, self.client_session._handles)
# stream over streaming API (full range of the largest file)