forked from LBRYCommunity/lbry-sdk
tests
This commit is contained in:
parent
7148767b6f
commit
f69d47587f
6 changed files with 9 additions and 39 deletions
|
@ -13,7 +13,7 @@ class BlobInfo:
|
|||
|
||||
def __init__(
|
||||
self, blob_num: int, length: int, iv: str,
|
||||
blob_hash: typing.Optional[str] = None, added_on=None, is_mine=None):
|
||||
blob_hash: typing.Optional[str] = None, added_on=0, is_mine=False):
|
||||
self.blob_hash = blob_hash
|
||||
self.blob_num = blob_num
|
||||
self.length = length
|
||||
|
|
|
@ -5,7 +5,7 @@ from lbry.testcase import AsyncioTestCase
|
|||
from lbry.conf import Config
|
||||
from lbry.extras import cli
|
||||
from lbry.extras.daemon.components import (
|
||||
DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
||||
DATABASE_COMPONENT, DISK_SPACE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
||||
HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
|
||||
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
|
||||
LIBTORRENT_COMPONENT
|
||||
|
@ -21,7 +21,7 @@ class CLIIntegrationTest(AsyncioTestCase):
|
|||
conf.share_usage_data = False
|
||||
conf.api = 'localhost:5299'
|
||||
conf.components_to_skip = (
|
||||
DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
||||
DATABASE_COMPONENT, DISK_SPACE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
||||
HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
|
||||
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
|
||||
LIBTORRENT_COMPONENT
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
import os
|
||||
import unittest
|
||||
import tempfile
|
||||
|
||||
import lbry.wallet
|
||||
from lbry.conf import Config
|
||||
from lbry.blob.disk_space_manager import DiskSpaceManager
|
||||
|
||||
|
||||
class ConfigurationTests(unittest.TestCase):
|
||||
|
||||
def test_space_management(self):
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
os.mkdir(os.path.join(temp_dir, 'blobfiles'))
|
||||
config = Config(
|
||||
blob_storage_limit=5,
|
||||
data_dir=temp_dir,
|
||||
wallet_dir=temp_dir,
|
||||
config=os.path.join(temp_dir, 'settings.yml'),
|
||||
)
|
||||
dsm = DiskSpaceManager(config)
|
||||
self.assertEqual(0, dsm.space_used_mb)
|
||||
for file_no in range(10):
|
||||
with open(os.path.join(config.data_dir, 'blobfiles', f'3mb-{file_no}'), 'w') as blob:
|
||||
blob.write('0' * 1 * 1024 * 1024)
|
||||
self.assertEqual(10, dsm.space_used_mb)
|
||||
self.assertTrue(dsm.clean())
|
||||
self.assertEqual(5, dsm.space_used_mb)
|
||||
self.assertFalse(dsm.clean())
|
||||
|
|
@ -3,7 +3,7 @@ from lbry.testcase import AsyncioTestCase, AdvanceTimeTestCase
|
|||
|
||||
from lbry.conf import Config
|
||||
from lbry.extras.daemon.componentmanager import ComponentManager
|
||||
from lbry.extras.daemon.components import DATABASE_COMPONENT, DHT_COMPONENT
|
||||
from lbry.extras.daemon.components import DATABASE_COMPONENT, DISK_SPACE_COMPONENT, DHT_COMPONENT
|
||||
from lbry.extras.daemon.components import HASH_ANNOUNCER_COMPONENT, UPNP_COMPONENT
|
||||
from lbry.extras.daemon.components import PEER_PROTOCOL_SERVER_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT
|
||||
from lbry.extras.daemon import components
|
||||
|
@ -15,7 +15,6 @@ class TestComponentManager(AsyncioTestCase):
|
|||
self.default_components_sort = [
|
||||
[
|
||||
components.DatabaseComponent,
|
||||
components.DiskSpaceComponent,
|
||||
components.ExchangeRateManagerComponent,
|
||||
components.TorrentComponent,
|
||||
components.UPnPComponent
|
||||
|
@ -26,6 +25,7 @@ class TestComponentManager(AsyncioTestCase):
|
|||
components.WalletComponent
|
||||
],
|
||||
[
|
||||
components.DiskSpaceComponent,
|
||||
components.FileManagerComponent,
|
||||
components.HashAnnouncerComponent,
|
||||
components.PeerProtocolServerComponent,
|
||||
|
@ -153,7 +153,7 @@ class TestComponentManagerProperStart(AdvanceTimeTestCase):
|
|||
self.component_manager = ComponentManager(
|
||||
Config(),
|
||||
skip_components=[
|
||||
DATABASE_COMPONENT, DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT,
|
||||
DATABASE_COMPONENT, DISK_SPACE_COMPONENT, DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT,
|
||||
PEER_PROTOCOL_SERVER_COMPONENT, UPNP_COMPONENT,
|
||||
EXCHANGE_RATE_MANAGER_COMPONENT],
|
||||
wallet=FakeDelayedWallet,
|
||||
|
|
|
@ -81,7 +81,7 @@ class StorageTest(AsyncioTestCase):
|
|||
await self.storage.close()
|
||||
|
||||
async def store_fake_blob(self, blob_hash, length=100):
|
||||
await self.storage.add_blobs((blob_hash, length), finished=True)
|
||||
await self.storage.add_blobs((blob_hash, length, 0, 0), finished=True)
|
||||
|
||||
async def store_fake_stream(self, stream_hash, blobs=None, file_name="fake_file", key="DEADBEEF"):
|
||||
blobs = blobs or [BlobInfo(1, 100, "DEADBEEF", random_lbry_hash())]
|
||||
|
|
|
@ -8,7 +8,7 @@ from lbry.testcase import AsyncioTestCase
|
|||
from lbry.conf import Config
|
||||
from lbry.extras.daemon.security import is_request_allowed as allowed, ensure_request_allowed as ensure
|
||||
from lbry.extras.daemon.components import (
|
||||
DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
||||
DATABASE_COMPONENT, DISK_SPACE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
||||
HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
|
||||
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
|
||||
LIBTORRENT_COMPONENT
|
||||
|
@ -69,7 +69,7 @@ class TestAccessHeaders(AsyncioTestCase):
|
|||
conf.share_usage_data = False
|
||||
conf.api = 'localhost:5299'
|
||||
conf.components_to_skip = (
|
||||
DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
||||
DATABASE_COMPONENT, DISK_SPACE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
||||
HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
|
||||
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
|
||||
LIBTORRENT_COMPONENT
|
||||
|
|
Loading…
Reference in a new issue