add lbry_file_manager to reflector server in functional reflector test, make sure file is added to lbry_file_manager when reflected
This commit is contained in:
parent
ab667015c4
commit
ae74d80c8a
1 changed files with 39 additions and 2 deletions
|
@ -52,7 +52,7 @@ class TestReflector(unittest.TestCase):
|
|||
1015056
|
||||
),
|
||||
]
|
||||
|
||||
## Setup reflector client classes ##
|
||||
self.db_dir, self.blob_dir = mk_db_and_blob_dir()
|
||||
self.session = Session.Session(
|
||||
conf.settings['data_rate'],
|
||||
|
@ -75,19 +75,39 @@ class TestReflector(unittest.TestCase):
|
|||
self.lbry_file_manager = EncryptedFileManager.EncryptedFileManager(
|
||||
self.session, self.stream_info_manager, sd_identifier)
|
||||
|
||||
## Setup reflector server classes ##
|
||||
self.server_db_dir, self.server_blob_dir = mk_db_and_blob_dir()
|
||||
self.server_session = Session.Session(
|
||||
conf.settings['data_rate'],
|
||||
db_dir=self.server_db_dir,
|
||||
node_id="abcd",
|
||||
peer_finder=peer_finder,
|
||||
hash_announcer=hash_announcer,
|
||||
blob_dir=self.server_blob_dir,
|
||||
peer_port=5553,
|
||||
use_upnp=False,
|
||||
wallet=wallet,
|
||||
blob_tracker_class=mocks.BlobAvailabilityTracker,
|
||||
external_ip="127.0.0.1"
|
||||
)
|
||||
|
||||
self.server_blob_manager = BlobManager.DiskBlobManager(
|
||||
hash_announcer, self.server_blob_dir, self.server_db_dir)
|
||||
self.server_stream_info_manager = \
|
||||
EncryptedFileMetadataManager.DBEncryptedFileMetadataManager(self.server_db_dir)
|
||||
|
||||
self.server_lbry_file_manager = EncryptedFileManager.EncryptedFileManager(
|
||||
self.server_session, self.server_stream_info_manager,
|
||||
sd_identifier)
|
||||
|
||||
d = self.session.setup()
|
||||
d.addCallback(lambda _: self.stream_info_manager.setup())
|
||||
d.addCallback(lambda _: EncryptedFileOptions.add_lbry_file_to_sd_identifier(sd_identifier))
|
||||
d.addCallback(lambda _: self.lbry_file_manager.setup())
|
||||
d.addCallback(lambda _: self.server_session.setup())
|
||||
d.addCallback(lambda _: self.server_blob_manager.setup())
|
||||
d.addCallback(lambda _: self.server_stream_info_manager.setup())
|
||||
d.addCallback(lambda _: self.server_lbry_file_manager.setup())
|
||||
|
||||
def verify_equal(sd_info):
|
||||
self.assertEqual(mocks.create_stream_sd_file, sd_info)
|
||||
|
@ -123,7 +143,8 @@ class TestReflector(unittest.TestCase):
|
|||
|
||||
def start_server():
|
||||
server_factory = reflector.ServerFactory(
|
||||
peer_manager, self.server_blob_manager, self.server_stream_info_manager)
|
||||
peer_manager, self.server_blob_manager, self.server_stream_info_manager,
|
||||
self.server_lbry_file_manager)
|
||||
from twisted.internet import reactor
|
||||
port = 8943
|
||||
while self.reflector_port is None:
|
||||
|
@ -140,14 +161,24 @@ class TestReflector(unittest.TestCase):
|
|||
|
||||
def take_down_env(self):
|
||||
d = defer.succeed(True)
|
||||
## Close client classes ##
|
||||
if self.lbry_file_manager is not None:
|
||||
d.addCallback(lambda _: self.lbry_file_manager.stop())
|
||||
if self.session is not None:
|
||||
d.addCallback(lambda _: self.session.shut_down())
|
||||
if self.stream_info_manager is not None:
|
||||
d.addCallback(lambda _: self.stream_info_manager.stop())
|
||||
|
||||
## Close server classes ##
|
||||
if self.server_blob_manager is not None:
|
||||
d.addCallback(lambda _: self.server_blob_manager.stop())
|
||||
if self.server_lbry_file_manager is not None:
|
||||
d.addCallback(lambda _: self.server_lbry_file_manager.stop())
|
||||
if self.server_session is not None:
|
||||
d.addCallback(lambda _: self.server_session.shut_down())
|
||||
if self.server_stream_info_manager is not None:
|
||||
d.addCallback(lambda _: self.server_stream_info_manager.stop())
|
||||
|
||||
if self.reflector_port is not None:
|
||||
d.addCallback(lambda _: self.reflector_port.stopListening())
|
||||
|
||||
|
@ -186,6 +217,12 @@ class TestReflector(unittest.TestCase):
|
|||
expected_sd_hash = self.expected_blobs[-1][0]
|
||||
self.assertEqual(self.sd_hash, sd_hashes[0])
|
||||
|
||||
# check lbry file manager has the file
|
||||
files = yield self.server_lbry_file_manager.lbry_files
|
||||
self.assertEqual(1, len(files))
|
||||
self.assertEqual(self.sd_hash, files[0].sd_hash)
|
||||
self.assertEqual('test_file', files[0].file_name)
|
||||
|
||||
# check should_announce blobs on blob_manager
|
||||
blob_hashes = yield self.server_blob_manager._get_all_should_announce_blob_hashes()
|
||||
self.assertEqual(2, len(blob_hashes))
|
||||
|
|
Loading…
Reference in a new issue