2018-08-10 16:06:05 +05:30
|
|
|
import contextlib
|
|
|
|
from io import StringIO
|
2019-12-31 15:30:13 -05:00
|
|
|
from lbry.testcase import AsyncioTestCase
|
2018-08-10 16:06:05 +05:30
|
|
|
|
2019-06-20 21:02:58 -04:00
|
|
|
from lbry.conf import Config
|
|
|
|
from lbry.extras import cli
|
2020-01-03 01:42:54 -05:00
|
|
|
from lbry.extras.daemon.components import (
|
2021-09-19 21:38:09 -04:00
|
|
|
DATABASE_COMPONENT, DISK_SPACE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
2020-01-27 19:02:31 -03:00
|
|
|
HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
|
2021-01-17 15:53:13 -05:00
|
|
|
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
|
|
|
|
LIBTORRENT_COMPONENT
|
2019-01-23 18:04:16 -05:00
|
|
|
)
|
2020-01-03 01:44:22 -05:00
|
|
|
from lbry.extras.daemon.daemon import Daemon
|
2018-08-10 16:06:05 +05:30
|
|
|
|
2019-10-26 13:33:43 -04:00
|
|
|
|
2018-12-12 22:32:44 -05:00
|
|
|
class CLIIntegrationTest(AsyncioTestCase):
|
2018-08-16 21:43:54 +05:30
|
|
|
|
2018-12-12 22:32:44 -05:00
|
|
|
async def asyncSetUp(self):
|
2019-01-21 23:28:26 -05:00
|
|
|
conf = Config()
|
|
|
|
conf.data_dir = '/tmp'
|
|
|
|
conf.share_usage_data = False
|
2019-01-22 15:40:45 -05:00
|
|
|
conf.api = 'localhost:5299'
|
2019-01-23 18:04:16 -05:00
|
|
|
conf.components_to_skip = (
|
2021-09-19 21:38:09 -04:00
|
|
|
DATABASE_COMPONENT, DISK_SPACE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
2020-01-27 19:02:31 -03:00
|
|
|
HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
|
2021-01-17 15:53:13 -05:00
|
|
|
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, WALLET_SERVER_PAYMENTS_COMPONENT,
|
|
|
|
LIBTORRENT_COMPONENT
|
2019-01-23 18:04:16 -05:00
|
|
|
)
|
2018-08-10 16:06:05 +05:30
|
|
|
Daemon.component_attributes = {}
|
2019-01-21 23:28:26 -05:00
|
|
|
self.daemon = Daemon(conf)
|
|
|
|
await self.daemon.start()
|
2019-10-26 13:33:43 -04:00
|
|
|
self.addCleanup(self.daemon.stop)
|
2018-08-16 21:43:54 +05:30
|
|
|
|
2018-08-15 13:56:07 +05:30
|
|
|
def test_cli_status_command_with_auth(self):
|
|
|
|
actual_output = StringIO()
|
|
|
|
with contextlib.redirect_stdout(actual_output):
|
2019-01-22 15:40:45 -05:00
|
|
|
cli.main(["--api", "localhost:5299", "status"])
|
2018-08-15 13:56:07 +05:30
|
|
|
actual_output = actual_output.getvalue()
|
2021-02-17 12:47:56 -05:00
|
|
|
self.assertIn("is_running", actual_output)
|