From b4e7141f4d6efc132f2ededca82bd5b4d4fdcfea Mon Sep 17 00:00:00 2001 From: Egbert Bouman Date: Thu, 11 Jun 2020 17:03:51 +0200 Subject: [PATCH] Fix GUI tests --- .../tests/fake_tribler_api/endpoints/ipv8_endpoint.py | 4 ++++ .../tribler_gui/tests/fake_tribler_api/tribler_data.py | 9 +++++++++ src/tribler-gui/tribler_gui/tests/test_gui.py | 8 ++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/tribler-gui/tribler_gui/tests/fake_tribler_api/endpoints/ipv8_endpoint.py b/src/tribler-gui/tribler_gui/tests/fake_tribler_api/endpoints/ipv8_endpoint.py index a7767776e6b..f5b715544e7 100644 --- a/src/tribler-gui/tribler_gui/tests/fake_tribler_api/endpoints/ipv8_endpoint.py +++ b/src/tribler-gui/tribler_gui/tests/fake_tribler_api/endpoints/ipv8_endpoint.py @@ -16,6 +16,7 @@ def setup_routes(self): web.get('/tunnel/relays', self.get_relays), web.get('/tunnel/exits', self.get_exits), web.get('/dht/statistics', self.get_dht_stats), + web.get('/dht/buckets', self.get_dht_buckets), web.get('/overlays', self.get_overlays), ] ) @@ -41,6 +42,9 @@ async def get_exits(self, _): async def get_dht_stats(self, _): return RESTResponse({"statistics": tribler_utils.tribler_data.dht_stats}) + async def get_dht_buckets(self, _): + return RESTResponse({"buckets": tribler_utils.tribler_data.dht_buckets}) + async def get_overlays(self, _): return RESTResponse( { diff --git a/src/tribler-gui/tribler_gui/tests/fake_tribler_api/tribler_data.py b/src/tribler-gui/tribler_gui/tests/fake_tribler_api/tribler_data.py index c19245bf84d..246198e5456 100644 --- a/src/tribler-gui/tribler_gui/tests/fake_tribler_api/tribler_data.py +++ b/src/tribler-gui/tribler_gui/tests/fake_tribler_api/tribler_data.py @@ -35,6 +35,7 @@ def __init__(self): self.transactions = [] self.orders = [] self.dht_stats = {} + self.dht_buckets = {} self.video_player_port = get_random_port() self.tunnel_circuits = [] self.tunnel_relays = [] @@ -50,6 +51,7 @@ def generate(self): self.generate_transactions() self.generate_orders() self.generate_dht_stats() + self.generate_dht_buckets() self.generate_tunnels() # Create settings @@ -259,6 +261,13 @@ def generate_dht_stats(self): "routing_table_size": randint(10, 50), } + def generate_dht_buckets(self): + self.dht_buckets = [{ + "prefix": format(randint(1, 7), '03b'), + "last_changed": randint(1500000000, 1590000000), + "peers": [] + }] + def generate_tunnels(self): self.tunnel_circuits = [Circuit() for _ in range(randint(2, 10))] self.tunnel_relays = [Relay() for _ in range(randint(2, 10))] diff --git a/src/tribler-gui/tribler_gui/tests/test_gui.py b/src/tribler-gui/tribler_gui/tests/test_gui.py index 0618b1afd3a..f4e15faaabf 100644 --- a/src/tribler-gui/tribler_gui/tests/test_gui.py +++ b/src/tribler-gui/tribler_gui/tests/test_gui.py @@ -489,8 +489,12 @@ def test_debug_pane(self): self.screenshot(window.debug_window, name="debug_panel_tunnel_exits_tab") window.debug_window.debug_tab_widget.setCurrentIndex(5) - self.wait_for_list_populated(window.debug_window.dht_tree_widget) - self.screenshot(window.debug_window, name="debug_panel_dht_tab") + self.wait_for_list_populated(window.debug_window.dhtstats_tree_widget) + self.screenshot(window.debug_window, name="debug_panel_dht_stats_tab") + + window.debug_window.dht_tab_widget.setCurrentIndex(1) + self.wait_for_list_populated(window.debug_window.buckets_tree_widget) + self.screenshot(window.debug_window, name="debug_panel_dht_buckets_tab") window.debug_window.debug_tab_widget.setCurrentIndex(6) self.wait_for_list_populated(window.debug_window.events_tree_widget)