lbry-sdk/tests/unit/blob/test_disk_space_manager.py

25 lines
813 B
Python
Raw Normal View History

2021-08-06 16:44:57 +02:00
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_calculation(self):
with tempfile.TemporaryDirectory() as temp_dir:
2021-08-06 16:52:47 +02:00
os.mkdir(os.path.join(temp_dir, 'blobfiles'))
2021-08-06 16:44:57 +02:00
config = Config(
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)
2021-08-06 16:52:47 +02:00
with open(os.path.join(config.data_dir, 'blobfiles', '3mb-file'), 'w') as blob:
2021-08-06 16:44:57 +02:00
blob.write('0' * 3 * 1024 * 1024)
self.assertEqual(3, dsm.space_used_mb)