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 54fb5d0 commit ae89581
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 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
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 test 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
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):
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
7 changes: 6 additions & 1 deletion tests/_test_mswms/test_wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
See the License for the specific language governing permissions and
limitations under the License.
"""

import time
import os
from shutil import move

Expand Down Expand Up @@ -407,6 +407,11 @@ def do_test():
nco = Nco()
nco.ncap2(input=os.path.join(DATA_DIR, pl_file), output=os.path.join(DATA_DIR, pl_file),
options=["-s \"geopotential_height*=2\""])
# Without waiting it is possible that the server did not yet see the changed files and responds with the old
# result. I have not found a better thing to wait on yet.
# TODO: Wait on some observable thing to avoid abusing time as a synchronization primitive. I.e. similar to
# how we use qtbot.wait_until in other places.
time.sleep(10)
result2 = self.client.get('/?{}'.format(environ["QUERY_STRING"]))
nco.ncap2(input=os.path.join(DATA_DIR, pl_file), output=os.path.join(DATA_DIR, pl_file),
options=["-s \"geopotential_height/=2\""])
Expand Down

0 comments on commit ae89581

Please sign in to comment.