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

57 lines
1.8 KiB
Python
Raw Normal View History

import contextlib
from io import StringIO
2018-12-13 04:32:44 +01:00
from torba.testcase import AsyncioTestCase
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
from lbrynet.extras.daemon.Components import DATABASE_COMPONENT, BLOB_COMPONENT, HEADERS_COMPONENT, WALLET_COMPONENT, \
DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, \
PEER_PROTOCOL_SERVER_COMPONENT, REFLECTOR_COMPONENT, UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, \
RATE_LIMITER_COMPONENT, PAYMENT_RATE_COMPONENT
from lbrynet.extras.daemon.Daemon import Daemon
2018-08-17 22:07:57 +02:00
class FakeAnalytics:
@property
def is_started(self):
return True
async def send_server_startup_success(self):
2018-08-17 22:07:57 +02:00
pass
async def send_server_startup(self):
2018-09-21 22:32:02 +02:00
pass
2018-08-17 22:07:57 +02:00
def shutdown(self):
pass
2018-12-13 04:32:44 +01:00
class CLIIntegrationTest(AsyncioTestCase):
2018-12-13 04:32:44 +01:00
async def asyncSetUp(self):
skip = [
DATABASE_COMPONENT, BLOB_COMPONENT, HEADERS_COMPONENT, WALLET_COMPONENT,
DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT,
PEER_PROTOCOL_SERVER_COMPONENT, REFLECTOR_COMPONENT, UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT,
RATE_LIMITER_COMPONENT, PAYMENT_RATE_COMPONENT
]
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-22 05:28:26 +01:00
conf.components_to_skip = skip
Daemon.component_attributes = {}
2019-01-22 05:28:26 +01:00
self.daemon = Daemon(conf)
await self.daemon.start()
2018-12-13 04:32:44 +01:00
async def asyncTearDown(self):
await self.daemon.shutdown()
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()
self.assertIn("connection_status", actual_output)