lbry-sdk/lbry/tests/integration/test_cli.py

37 lines
1.4 KiB
Python
Raw Normal View History

import contextlib
from io import StringIO
from lbry.wallet.testcase import AsyncioTestCase
from lbry.conf import Config
from lbry.extras import cli
from lbry.extras.daemon.Components import (
2019-09-27 14:26:35 +02:00
DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
2019-01-24 00:04:16 +01:00
HASH_ANNOUNCER_COMPONENT, STREAM_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT
)
from lbry.extras.daemon.Daemon import Daemon
2018-12-13 04:32:44 +01:00
class CLIIntegrationTest(AsyncioTestCase):
2018-12-13 04:32:44 +01:00
async def asyncSetUp(self):
2019-01-22 05:28:26 +01:00
conf = Config()
conf.data_dir = '/tmp'
conf.share_usage_data = False
conf.api = 'localhost:5299'
2019-01-24 00:04:16 +01:00
conf.components_to_skip = (
2019-09-27 14:26:35 +02:00
DATABASE_COMPONENT, BLOB_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
2019-01-24 00:04:16 +01:00
HASH_ANNOUNCER_COMPONENT, STREAM_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT
)
Daemon.component_attributes = {}
2019-01-22 05:28:26 +01:00
self.daemon = Daemon(conf)
await self.daemon.start()
self.addCleanup(self.daemon.stop)
def test_cli_status_command_with_auth(self):
actual_output = StringIO()
with contextlib.redirect_stdout(actual_output):
cli.main(["--api", "localhost:5299", "status"])
actual_output = actual_output.getvalue()
2019-10-16 18:38:02 +02:00
self.assertIn("connection_status", actual_output)