2017-02-17 23:08:01 +01:00
|
|
|
import os.path
|
|
|
|
from twisted.trial import unittest
|
|
|
|
from twisted.internet import defer
|
2017-06-26 03:03:37 +02:00
|
|
|
from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileSaver
|
2017-02-17 23:08:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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')
|
2017-02-17 23:08:01 +01:00
|
|
|
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 = '.'
|
2017-12-29 20:09:54 +01:00
|
|
|
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)
|
2017-02-17 23:08:01 +01:00
|
|
|
|
|
|
|
yield saver._setup_output()
|
|
|
|
self.assertTrue(os.path.isfile(file_name))
|
|
|
|
saver._close_output()
|