Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use dialog fixtures and fix flaky tests #1249

Merged
merged 1 commit into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import pytest
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QMainWindow

from securedrop_client.app import configure_locale_and_language
from securedrop_client.config import Config
Expand All @@ -21,7 +22,9 @@
make_session_maker,
)
from securedrop_client.gui.main import Window
from securedrop_client.gui.widgets import ExportDialog, ModalDialog, PrintDialog
from securedrop_client.logic import Controller
from tests import factory

with open(os.path.join(os.path.dirname(__file__), "files", "test-key.gpg.pub.asc")) as f:
PUB_KEY = f.read()
Expand All @@ -48,6 +51,49 @@
TIME_FILE_DOWNLOAD = 5000


@pytest.fixture(scope="function")
def modal_dialog(mocker, homedir):
mocker.patch(
"securedrop_client.gui.widgets.QApplication.activeWindow", return_value=QMainWindow()
)

dialog = ModalDialog()

yield dialog


@pytest.fixture(scope="function")
def print_dialog(mocker, homedir):
mocker.patch(
"securedrop_client.gui.widgets.QApplication.activeWindow", return_value=QMainWindow()
)

file = factory.File(source=factory.Source(), is_downloaded=True)
get_file = mocker.MagicMock(return_value=file)
controller = mocker.MagicMock(get_file=get_file)
controller.qubes = False

dialog = PrintDialog(controller, file.uuid, "file123.jpg")

yield dialog


@pytest.fixture(scope="function")
def export_dialog(mocker, homedir):
mocker.patch(
"securedrop_client.gui.widgets.QApplication.activeWindow", return_value=QMainWindow()
)

file = factory.File(source=factory.Source(), is_downloaded=True)
get_file = mocker.MagicMock(return_value=file)
controller = mocker.MagicMock(get_file=get_file)
controller.qubes = False

dialog = ExportDialog(controller, file.uuid, "file123.jpg")

yield dialog


@pytest.fixture(scope="function")
def i18n():
"""
Expand Down