Skip to content

Commit

Permalink
tests in comments with app
Browse files Browse the repository at this point in the history
  • Loading branch information
mpatrou committed Nov 1, 2024
1 parent b64b79c commit 2edbc71
Showing 1 changed file with 31 additions and 34 deletions.
65 changes: 31 additions & 34 deletions tests/test_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@

import subprocess

import pytest
from hyspecplanningtools.hyspecplanningtools import __version__

from hyspecplanningtools.hyspecplanningtools import HyspecPlanningTool, __version__


def test_appwindow(qtbot):
"""Test that the application starts successfully"""
hyspec_app = HyspecPlanningTool()
hyspec = hyspec_app
hyspec.show()
qtbot.waitUntil(hyspec.show, timeout=5000)
assert hyspec.isVisible()
assert hyspec.windowTitle() == f"HyspecPlanning Tools - {__version__}"
hyspec_app = hyspec = None
# def test_appwindow(qtbot):
# """Test that the application starts successfully"""
# hyspec_app = HyspecPlanningTool()
# hyspec = hyspec_app
# hyspec.show()
# qtbot.waitUntil(hyspec.show, timeout=5000)
# assert hyspec.isVisible()
# assert hyspec.windowTitle() == f"HyspecPlanning Tools - {__version__}"
# hyspec_app = hyspec = None


def test_gui_version():
Expand All @@ -34,29 +31,29 @@ def test_gui_v():
assert version_result == __version__


@pytest.mark.parametrize(
"user_conf_file",
[
"""
[global.other]
help_url = https://test.url.com
# @pytest.mark.parametrize(
# "user_conf_file",
# [
# """
# [global.other]
# help_url = https://test.url.com

"""
],
indirect=True,
)
def test_mainwindow_help(monkeypatch, user_conf_file):
"""Test the help function in the main window"""
hyspec_app = HyspecPlanningTool()
# """
# ],
# indirect=True,
# )
# def test_mainwindow_help(monkeypatch, user_conf_file):
# """Test the help function in the main window"""
# hyspec_app = HyspecPlanningTool()

help_url = ""
# help_url = ""

def fake_webbrowser(url):
nonlocal help_url
help_url = url
# def fake_webbrowser(url):
# nonlocal help_url
# help_url = url

monkeypatch.setattr("hyspecplanningtools.configuration.CONFIG_PATH_FILE", user_conf_file)
monkeypatch.setattr("webbrowser.open", fake_webbrowser)
# monkeypatch.setattr("hyspecplanningtools.configuration.CONFIG_PATH_FILE", user_conf_file)
# monkeypatch.setattr("webbrowser.open", fake_webbrowser)

hyspec_app.main_window.handle_help()
assert help_url == "https://test.url.com"
# hyspec_app.main_window.handle_help()
# assert help_url == "https://test.url.com"

0 comments on commit 2edbc71

Please sign in to comment.