lbry-sdk/lbrynet/tests/unit/lbryfile/client/test_EncryptedFileDownloader.py

35 lines
1.1 KiB
Python
Raw Normal View History

import os.path
from twisted.trial import unittest
from twisted.internet import defer
from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileSaver
class TestEncryptedFileSaver(unittest.TestCase):
@defer.inlineCallbacks
def test_setup_output(self):
file_name = 'encrypted_file_saver_test.tmp'
2018-01-05 03:28:09 +01:00
file_name_hex = file_name.encode('hex')
self.assertFalse(os.path.isfile(file_name))
# create file in the temporary trial folder
stream_hash = ''
peer_finder = None
rate_limiter = None
blob_manager = None
stream_info_manager = None
payment_rate_manager = None
wallet = None
download_directory = '.'
key = ''
saver = EncryptedFileSaver(stream_hash, peer_finder, rate_limiter, blob_manager,
stream_info_manager, payment_rate_manager, wallet,
2018-01-05 03:28:09 +01:00
download_directory, key,
file_name_hex, file_name_hex)
yield saver._setup_output()
self.assertTrue(os.path.isfile(file_name))
saver._close_output()