async def test_rest_component(tribler_config): components = [ KeyComponent(), RESTComponent(), Ipv8Component(), LibtorrentComponent(), ResourceMonitorComponent(), BandwidthAccountingComponent(), GigaChannelComponent(), TagComponent(), SocksServersComponent(), MetadataStoreComponent() ] async with Session(tribler_config, components).start(): # Test REST component starts normally comp = RESTComponent.instance() assert comp.started_event.is_set() and not comp.failed assert comp.rest_manager # Test report callback works # mock callbacks comp._events_endpoint.on_tribler_exception = MagicMock() # try to call report_callback from core_exception_handler and assert # that corresponding methods in events_endpoint and state_endpoint have been called error = ReportedError(type='', text='text', event={}) comp._core_exception_handler.report_callback(error) comp._events_endpoint.on_tribler_exception.assert_called_with(error)
def components_gen(): yield KeyComponent() yield RESTComponent() yield Ipv8Component() yield ResourceMonitorComponent() yield BandwidthAccountingComponent() yield SocksServersComponent() yield TunnelsComponent()
def __init__(self, working_dir, config_path): super().__init__(Service.create_config(working_dir, config_path), working_dir=working_dir, components=[ Ipv8Component(), KeyComponent(), RESTComponent(), TunnelsComponent() ]) TaskManager.__init__(self) self.results = [] self.output_file = 'speed_test_exit.txt'
def __init__(self, timeout_in_sec, working_dir): super().__init__(config=TriblerConfig(state_dir=working_dir), timeout_in_sec=timeout_in_sec, working_dir=working_dir, components=[ SocksServersComponent(), LibtorrentComponent(), TorrentCheckerComponent(), MetadataStoreComponent(), KeyComponent(), RESTComponent(), Ipv8Component(), ObservablePopularityComponent() ])
def __init__(self, source_dir, working_dir): super().__init__(TriblerConfig(state_dir=working_dir), working_dir=working_dir, components=[ RESTComponent(), KeyComponent(), SocksServersComponent(), LibtorrentComponent(), Ipv8Component(), MetadataStoreComponent(), GigachannelManagerComponent(), GigaChannelComponent() ]) self.source_dir = Path(source_dir)
def __init__(self, working_dir, config_path): super().__init__(Service.create_config(working_dir, config_path), working_dir=working_dir, components=[ Ipv8Component(), KeyComponent(), RESTComponent(), TunnelsComponent() ]) TaskManager.__init__(self) self.swarm = None self.start = time.time() self.results = [] self.register_task('monitor_swarm', self.monitor_swarm, interval=5) self.register_task('_graceful_shutdown', self._graceful_shutdown, delay=EXPERIMENT_RUN_TIME)
def components_gen(config: TriblerConfig): """This function defines components that will be used in Tibler """ yield ReporterComponent() if config.api.http_enabled or config.api.https_enabled: yield RESTComponent() if config.chant.enabled or config.torrent_checking.enabled: yield MetadataStoreComponent() if config.ipv8.enabled: yield Ipv8Component() yield KeyComponent() yield TagComponent() if config.libtorrent.enabled: yield LibtorrentComponent() if config.ipv8.enabled and config.chant.enabled: yield GigaChannelComponent() if config.ipv8.enabled: yield BandwidthAccountingComponent() if config.resource_monitor.enabled: yield ResourceMonitorComponent() # The components below are skipped if config.gui_test_mode == True if config.gui_test_mode: return if config.libtorrent.enabled: yield SocksServersComponent() if config.torrent_checking.enabled: yield TorrentCheckerComponent() if config.ipv8.enabled and config.torrent_checking.enabled and config.popularity_community.enabled: yield PopularityComponent() if config.ipv8.enabled and config.tunnel_community.enabled: yield TunnelsComponent() if config.ipv8.enabled: yield PayoutComponent() if config.watch_folder.enabled: yield WatchFolderComponent() if config.general.version_checker_enabled: yield VersionCheckComponent() if config.chant.enabled and config.chant.manager_enabled and config.libtorrent.enabled: yield GigachannelManagerComponent()
def rest_component(): component = RESTComponent() component.root_endpoint = MagicMock() return component