Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vxgmichel committed Jul 20, 2021
1 parent a987114 commit 3fcfe68
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
29 changes: 21 additions & 8 deletions tests/core/gui/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import qtrio
import pytest
from PyQt5 import QtCore
from pytestqt import exceptions as pytestqt_exceptions

from parsec import __version__ as parsec_version
from parsec.core.local_device import save_device_with_password
Expand Down Expand Up @@ -108,17 +109,29 @@ async def wait_signal(self, signal, *, timeout=5000):

@asynccontextmanager
async def wait_active(self, widget, *, timeout=5000):
with self.qtbot.wait_active(widget, timeout=timeout):
yield
# TODO: make qtbot.wait_active compatible with trio
await trio.sleep(0.2)
yield
deadline = time.time() + timeout / 1000
while time.time() < deadline:
try:
with self.qtbot.wait_active(widget, timeout=10):
await trio.sleep(0.01)
except pytestqt_exceptions.TimeoutError:
continue
else:
return

@asynccontextmanager
async def wait_exposed(self, widget, *, timeout=5000):
with self.qtbot.wait_exposed(widget, timeout=timeout):
yield
# TODO: make qtbot.wait_exposed compatible with trio
await trio.sleep(0.2)
yield
deadline = time.time() + timeout / 1000
while time.time() < deadline:
try:
with self.qtbot.wait_exposed(widget, timeout=10):
await trio.sleep(0.01)
except pytestqt_exceptions.TimeoutError:
continue
else:
return


@pytest.fixture
Expand Down
15 changes: 2 additions & 13 deletions tests/core/gui/test_create_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ def _next_page_ready():
async def test_create_organization_bootstrap_only(
aqtbot,
running_backend,
qt_thread_gateway,
catch_create_org_widget,
autoclose_dialog,
gui_factory,
Expand Down Expand Up @@ -301,7 +300,6 @@ def _modal_shown():
async def test_create_organization_bootstrap_only_custom_server(
aqtbot,
running_backend,
qt_thread_gateway,
catch_create_org_widget,
autoclose_dialog,
gui_factory,
Expand Down Expand Up @@ -441,13 +439,7 @@ def _modal_shown():
@customize_fixtures(backend_spontaneous_organization_boostrap=True)
@customize_fixtures(fake_preferred_org_creation_backend_addr=True)
async def test_create_organization_custom_backend(
gui,
aqtbot,
running_backend,
catch_create_org_widget,
autoclose_dialog,
unused_tcp_port,
qt_thread_gateway,
gui, aqtbot, running_backend, catch_create_org_widget, autoclose_dialog, unused_tcp_port
):
# The org creation window is usually opened using a sub-menu.
# Sub-menus can be a bit challenging to open in tests so we cheat
Expand Down Expand Up @@ -517,11 +509,8 @@ def _user_widget_ready_again():

await aqtbot.wait_until(_user_widget_ready_again)

def _select_radio_custom():
co_w.user_widget.radio_use_custom.setChecked(True)

# Clicking the radio doesn't do anything, so we cheat
await qt_thread_gateway.send_action(_select_radio_custom)
co_w.user_widget.radio_use_custom.setChecked(True)

await aqtbot.key_clicks(co_w.user_widget.line_edit_backend_addr, running_backend.addr.to_url())
await aqtbot.wait_until(_user_widget_button_validate_ready)
Expand Down

0 comments on commit 3fcfe68

Please sign in to comment.