32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
import pytest
|
|
import sys
|
|
from unittest.mock import MagicMock, patch
|
|
from aare.common.beamline import MXBeamline
|
|
from aare.gui.gui import main
|
|
|
|
# We need to mock things that gui.py uses at module level or during startup
|
|
@patch("aare.gui.gui.QApplication")
|
|
@patch("aare.gui.gui.MainWindow")
|
|
@patch("aare.gui.gui.auth")
|
|
@patch("aare.gui.gui.mx_beamline")
|
|
def test_gui_main_startup(mock_mx, mock_auth, mock_win, mock_app):
|
|
mock_mx.return_value = MXBeamline.X06DA
|
|
mock_auth.return_value = "header.payload.signature"
|
|
|
|
# Mock QApplication instance and its exec method
|
|
mock_app_instance = mock_app.return_value
|
|
mock_app_instance.exec.return_value = 0
|
|
|
|
with patch("aare.gui.gui.QCommandLineParser") as mock_parser:
|
|
# Simulate sys.argv
|
|
with patch.object(sys, 'argv', ['gui.py']):
|
|
try:
|
|
main()
|
|
except SystemExit:
|
|
pass # Expected from sys.exit()
|
|
|
|
mock_app.assert_called()
|
|
mock_auth.assert_called()
|
|
mock_win.assert_called()
|
|
mock_win.return_value.show.assert_called()
|