2018-08-10 12:36:05 +02:00
|
|
|
import contextlib
|
|
|
|
from io import StringIO
|
2018-12-13 04:32:44 +01:00
|
|
|
from torba.testcase import AsyncioTestCase
|
2018-08-10 12:36:05 +02:00
|
|
|
|
2019-01-22 05:28:26 +01:00
|
|
|
from lbrynet.conf import Config
|
2018-11-07 21:15:05 +01:00
|
|
|
from lbrynet.extras import cli
|
2019-01-24 00:04:16 +01:00
|
|
|
from lbrynet.extras.daemon.Components import (
|
|
|
|
DATABASE_COMPONENT, BLOB_COMPONENT, HEADERS_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
|
|
|
HASH_ANNOUNCER_COMPONENT, STREAM_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
|
|
|
|
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT
|
|
|
|
)
|
2018-11-04 19:44:17 +01:00
|
|
|
from lbrynet.extras.daemon.Daemon import Daemon
|
2018-08-10 12:36:05 +02:00
|
|
|
|
|
|
|
|
2018-12-13 04:32:44 +01:00
|
|
|
class CLIIntegrationTest(AsyncioTestCase):
|
2018-08-16 18:13:54 +02:00
|
|
|
|
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
|
2019-01-22 21:40:45 +01:00
|
|
|
conf.api = 'localhost:5299'
|
2019-01-24 00:04:16 +01:00
|
|
|
conf.components_to_skip = (
|
|
|
|
DATABASE_COMPONENT, BLOB_COMPONENT, HEADERS_COMPONENT, WALLET_COMPONENT, DHT_COMPONENT,
|
|
|
|
HASH_ANNOUNCER_COMPONENT, STREAM_MANAGER_COMPONENT, PEER_PROTOCOL_SERVER_COMPONENT,
|
|
|
|
UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT
|
|
|
|
)
|
2018-08-10 12:36:05 +02:00
|
|
|
Daemon.component_attributes = {}
|
2019-01-22 05:28:26 +01:00
|
|
|
self.daemon = Daemon(conf)
|
|
|
|
await self.daemon.start()
|
2018-08-04 23:19:10 +02:00
|
|
|
|
2018-12-13 04:32:44 +01:00
|
|
|
async def asyncTearDown(self):
|
2019-05-04 02:50:11 +02:00
|
|
|
await self.daemon.stop(shutdown_runner=False)
|
2018-08-16 18:13:54 +02:00
|
|
|
|
2018-08-15 10:26:07 +02:00
|
|
|
def test_cli_status_command_with_auth(self):
|
|
|
|
actual_output = StringIO()
|
|
|
|
with contextlib.redirect_stdout(actual_output):
|
2019-01-22 21:40:45 +01:00
|
|
|
cli.main(["--api", "localhost:5299", "status"])
|
2018-08-15 10:26:07 +02:00
|
|
|
actual_output = actual_output.getvalue()
|
|
|
|
self.assertIn("connection_status", actual_output)
|