Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
matrss committed Feb 27, 2024
1 parent 679ba31 commit 0a5d337
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
9 changes: 8 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def generate_initial_config():
examples = DataFiles(data_fs=constants.DATA_FS,
server_config_fs=constants.SERVER_CONFIG_FS)
examples.create_server_config(detailed_information=True)
examples.create_data()
if constants.DATA_FS.isempty("/"):
examples.create_data()

if not constants.SERVER_CONFIG_FS.exists(constants.MSCOLAB_CONFIG_FILE):
config_string = f'''
Expand Down Expand Up @@ -220,9 +221,15 @@ def reset_config():
"""Reset the configuration directory used in the tests (tests.constants.ROOT_FS) after every test
"""
# Ideally this would just be constants.ROOT_FS.removetree("/"), but SQLAlchemy complains if the SQLite file is deleted.
# Also, on Windows there are issues with files in msui/testdata being held open in another process, so those are
# excluded as well. This shouldn't be a problem since they are meant to be static anyway.
for e in constants.ROOT_FS.walk.files(exclude=["mscolab.db"]):
if fs.path.isbase("/msui/testdata", e):
continue
constants.ROOT_FS.remove(e)
for e in constants.ROOT_FS.walk.dirs(search="depth"):
if e == "/msui" or fs.path.isbase("/msui/testdata", e):
continue
constants.ROOT_FS.removedir(e)

generate_initial_config()
Expand Down
2 changes: 1 addition & 1 deletion tests/_test_msui/test_linearview.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,5 @@ def test_server_getmap(self, qtbot):
assert that a getmap call to a WMS server displays an image
"""
self.query_server(self.url)
with qtbot.wait_signal(self.wms_control.image_displayed):
with qtbot.wait_signal(self.wms_control.image_displayed, timeout=30000):
QtTest.QTest.mouseClick(self.wms_control.btGetMap, QtCore.Qt.LeftButton)
5 changes: 5 additions & 0 deletions tests/_test_msui/test_mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
limitations under the License.
"""
import os
import sys
import fs
import fs.errors
import fs.opener.errors
Expand Down Expand Up @@ -350,6 +351,10 @@ def test_handle_export(self, mockbox, qtbot):
for i in range(wp_count):
assert exported_waypoints.waypoint_data(i).lat == self.window.mscolab.waypoints_model.waypoint_data(i).lat

@pytest.mark.skipif(
sys.platform != "darwin",
reason="This is flaky on MacOS because of some cleanup error in temporary files.",
)
@pytest.mark.parametrize("name", [("example.ftml", "actionImportFlightTrackFTML", 5),
("example.csv", "actionImportFlightTrackCSV", 5),
("example.txt", "actionImportFlightTrackTXT", 5),
Expand Down
2 changes: 1 addition & 1 deletion tests/_test_msui/test_sideview.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_server_getmap(self, qtbot):
assert that a getmap call to a WMS server displays an image
"""
self.query_server(self.url)
with qtbot.wait_signal(self.wms_control.image_displayed):
with qtbot.wait_signal(self.wms_control.image_displayed, timeout=30000):
QtTest.QTest.mouseClick(self.wms_control.btGetMap, QtCore.Qt.LeftButton)
assert self.window.getView().plotter.image is not None

Expand Down
6 changes: 3 additions & 3 deletions tests/_test_msui/test_topview.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ def query_server(self, url):
QtTest.QTest.mouseClick(self.wms_control.multilayers.btGetCapabilities, QtCore.Qt.LeftButton)
wait_until_signal(self.wms_control.cpdlg.canceled)

def test_server_getmap(self):
def test_server_getmap(self, qtbot):
"""
assert that a getmap call to a WMS server displays an image
"""
self.query_server(self.url)
QtTest.QTest.mouseClick(self.wms_control.btGetMap, QtCore.Qt.LeftButton)
wait_until_signal(self.wms_control.image_displayed)
with qtbot.wait_signal(self.wms_control.image_displayed, timeout=30000):
QtTest.QTest.mouseClick(self.wms_control.btGetMap, QtCore.Qt.LeftButton)
assert self.window.getView().map.image is not None
self.window.getView().set_settings({})
self.window.getView().clear_figure()
Expand Down
6 changes: 3 additions & 3 deletions tests/_test_msui/test_wms_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def test_server_getmap(self, qtbot):
"""
self.query_server(self.url)

with qtbot.wait_signal(self.window.image_displayed):
with qtbot.wait_signal(self.window.image_displayed, timeout=30000):
QtTest.QTest.mouseClick(self.window.btGetMap, QtCore.Qt.LeftButton)

assert self.view.draw_image.call_count == 1
Expand All @@ -195,7 +195,7 @@ def test_server_getmap_cached(self, qtbot):
"""
self.query_server(self.url)

with qtbot.wait_signal(self.window.image_displayed):
with qtbot.wait_signal(self.window.image_displayed, timeout=30000):
QtTest.QTest.mouseClick(self.window.btGetMap, QtCore.Qt.LeftButton)

assert self.view.draw_image.call_count == 1
Expand Down Expand Up @@ -421,7 +421,7 @@ def test_server_getmap(self, qtbot):
assert that a getmap call to a WMS server displays an image
"""
self.query_server(self.url)
with qtbot.wait_signal(self.window.image_displayed):
with qtbot.wait_signal(self.window.image_displayed, timeout=30000):
QtTest.QTest.mouseClick(self.window.btGetMap, QtCore.Qt.LeftButton)

assert self.view.draw_image.call_count == 1
Expand Down

0 comments on commit 0a5d337

Please sign in to comment.