Skip to content

Commit

Permalink
Remove unnecessary skips (#2165)
Browse files Browse the repository at this point in the history
  • Loading branch information
matrss authored Feb 16, 2024
1 parent c73d9ba commit 579e577
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 66 deletions.
10 changes: 4 additions & 6 deletions tests/_test_msui/test_mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ def test_import_file(self, name):
imported_wp = self.window.mscolab.waypoints_model
assert len(imported_wp.waypoints) == name[2]

@pytest.mark.skip("Runs in a timeout locally > 60s")
def test_work_locally_toggle(self):
self._connect_to_mscolab()
modify_config_file({"MSS_auth": {self.url: self.userdata[0]}})
Expand All @@ -408,10 +407,8 @@ def test_work_locally_toggle(self):
wpdata_server = self.window.mscolab.waypoints_model.waypoint_data(0)
assert wpdata_local.lat != wpdata_server.lat

@pytest.mark.skip("fails often on github on a timeout >60s")
@mock.patch("mslib.msui.mscolab.QtWidgets.QErrorMessage.showMessage")
@mock.patch("mslib.msui.mscolab.get_open_filename", return_value=os.path.join(sample_path, u"example.ftml"))
def test_browse_add_operation(self, mockopen, mockmessage, qtbot):
def test_browse_add_operation(self, mockopen, qtbot):
self._connect_to_mscolab()
modify_config_file({"MSS_auth": {self.url: "something@something.org"}})
self._create_user(qtbot, "something", "something@something.org", "something")
Expand All @@ -428,7 +425,9 @@ def test_browse_add_operation(self, mockopen, mockmessage, qtbot):
QtWidgets.QApplication.processEvents()
okWidget = self.window.mscolab.add_proj_dialog.buttonBox.button(
self.window.mscolab.add_proj_dialog.buttonBox.Ok)
QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
with mock.patch("PyQt5.QtWidgets.QMessageBox.information") as m:
QtTest.QTest.mouseClick(okWidget, QtCore.Qt.LeftButton)
m.assert_called_once()
# we need to wait for the update of the operation list
QtTest.QTest.qWait(200)
QtWidgets.QApplication.processEvents()
Expand Down Expand Up @@ -461,7 +460,6 @@ def test_add_operation(self, qtbot):

@mock.patch("PyQt5.QtWidgets.QInputDialog.getText", return_value=("flight7", True))
def test_handle_delete_operation(self, mocktext, qtbot):
# pytest.skip('needs a review for the delete button pressed. Seems to delete a None operation')
self._connect_to_mscolab()
modify_config_file({"MSS_auth": {self.url: "berta@something.org"}})
self._create_user(qtbot, "berta", "berta@something.org", "something")
Expand Down
7 changes: 4 additions & 3 deletions tests/_test_msui/test_mscolab_save_merge_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
import pytest
import mock
from tests._test_msui.test_mscolab_merge_waypoints import Test_Mscolab_Merge_Waypoints
from mslib.msui import flighttrack as ft
from PyQt5 import QtCore, QtTest, QtWidgets


@pytest.mark.skip("Uses QTimer, which can break other unrelated tests")
class Test_Save_Merge_Points(Test_Mscolab_Merge_Waypoints):
def test_save_merge_points(self):
self.emailid = "mergepoints@alpha.org"
Expand All @@ -53,7 +52,9 @@ def handle_merge_dialog():
QtCore.QTimer.singleShot(3000, handle_merge_dialog)
# QtTest.QTest.mouseClick(self.window.save_ft, QtCore.Qt.LeftButton, delay=1)
# trigger save to server action from server options combobox
self.window.serverOptionsCb.setCurrentIndex(2)
with mock.patch("PyQt5.QtWidgets.QMessageBox.information") as m:
self.window.serverOptionsCb.setCurrentIndex(2)
m.assert_called_once()
QtWidgets.QApplication.processEvents()
# get the updated waypoints model from the server
# ToDo understand why requesting in follow up test of self.window.waypoints_model not working
Expand Down
2 changes: 0 additions & 2 deletions tests/_test_msui/test_mss.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
import pytest
from PyQt5 import QtWidgets, QtTest, QtCore
from mslib.msui import mss


@pytest.mark.skip(reason='needs review, assert missing')
def test_mss_rename_message(qapp):
main_window = mss.MSSMainWindow()
main_window.show()
Expand Down
21 changes: 10 additions & 11 deletions tests/_test_msui/test_msui.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,10 @@ def test_open_about(self):
QtWidgets.QApplication.processEvents()

def test_open_config(self):
pytest.skip("To be done")
self.window.actionConfigurationEditor.trigger()
self.window.actionConfiguration.trigger()
QtWidgets.QApplication.processEvents()
self.window.config_editor.close()
with mock.patch("PyQt5.QtWidgets.QMessageBox.warning", return_value=QtWidgets.QMessageBox.Yes):
self.window.config_editor.close()

def test_open_shortcut(self):
self.window.actionShortcuts.trigger()
Expand Down Expand Up @@ -298,21 +298,20 @@ def test_plugin_export(self, save_file):
assert os.path.exists(save_file[0])
os.remove(save_file[0])

@pytest.mark.skip("needs to be refactored to become independent")
@mock.patch("mslib.msui.msui_mainwindow.config_loader", return_value=export_plugins)
def test_add_plugins(self, mockopen, mockbox):
def test_add_plugins(self, mockopen):
assert len(self.window.menuImportFlightTrack.actions()) == 2
assert len(self.window.menuExportActiveFlightTrack.actions()) == 2
assert len(self.window.import_plugins) == 1
assert len(self.window.export_plugins) == 1
assert len(self.window.import_plugins) == 0
assert len(self.window.export_plugins) == 0

self.window.remove_plugins()
self.window.add_import_plugins("qt")
self.window.add_export_plugins("qt")
assert len(self.window.import_plugins) == 1
assert len(self.window.export_plugins) == 1
assert len(self.window.menuImportFlightTrack.actions()) == 2
assert len(self.window.menuExportActiveFlightTrack.actions()) == 2
assert len(self.window.menuImportFlightTrack.actions()) == 3
assert len(self.window.menuExportActiveFlightTrack.actions()) == 3

self.window.remove_plugins()
with mock.patch("importlib.import_module", new=ExceptionMock(Exception()).raise_exc), \
Expand All @@ -333,8 +332,8 @@ def test_add_plugins(self, mockopen, mockbox):
self.window.remove_plugins()
assert len(self.window.import_plugins) == 0
assert len(self.window.export_plugins) == 0
assert len(self.window.menuImportFlightTrack.actions()) == 1
assert len(self.window.menuExportActiveFlightTrack.actions()) == 1
assert len(self.window.menuImportFlightTrack.actions()) == 2
assert len(self.window.menuExportActiveFlightTrack.actions()) == 2

@mock.patch("PyQt5.QtWidgets.QMessageBox.warning", return_value=QtWidgets.QMessageBox.Yes)
@mock.patch("PyQt5.QtWidgets.QMessageBox.information", return_value=QtWidgets.QMessageBox.Yes)
Expand Down
1 change: 0 additions & 1 deletion tests/_test_msui/test_sideview.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def test_options(self, mockdlg):
assert mockdlg.return_value.exec_.call_count == 1
assert mockdlg.return_value.destroy.call_count == 1

@pytest.mark.skip("fails with mockbox.critical.call_count in reverse order")
def test_insert_point(self):
"""
Test inserting a point inside and outside the canvas
Expand Down
41 changes: 17 additions & 24 deletions tests/_test_msui/test_wms_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ def test_invalid_url(self, mockbox):
self.query_server(f"{self.scheme}://???{self.host}:{self.port}")
assert mockbox.critical.call_count == 1

@pytest.mark.skip("problem in urllib3")
@mock.patch("PyQt5.QtWidgets.QMessageBox")
def test_connection_error(self, mockbox):
"""
Expand Down Expand Up @@ -226,32 +225,29 @@ def test_server_getmap_cached(self, qtbot):
assert self.view.draw_legend.call_count == 1
assert self.view.draw_metadata.call_count == 1

@pytest.mark.skip("needs a review")
def test_server_service_cache(self):
def test_server_service_cache(self, qtbot):
"""
assert that changing between servers still allows image retrieval
"""
self.query_server(self.url)

QtTest.QTest.keyClick(self.window.multilayers.cbWMS_URL, QtCore.Qt.Key_Backspace)
QtTest.QTest.keyClick(self.window.multilayers.cbWMS_URL, QtCore.Qt.Key_Backspace)
QtWidgets.QApplication.processEvents()
QtTest.QTest.mouseClick(self.window.multilayers.btGetCapabilities, QtCore.Qt.LeftButton)
QtWidgets.QApplication.processEvents()
wait_until_signal(self.window.cpdlg.canceled)
with mock.patch("PyQt5.QtWidgets.QMessageBox.critical") as qm_critical:
with qtbot.wait_signal(self.window.cpdlg.canceled):
QtTest.QTest.keyClick(self.window.multilayers.cbWMS_URL, QtCore.Qt.Key_Backspace)
QtTest.QTest.keyClick(self.window.multilayers.cbWMS_URL, QtCore.Qt.Key_Backspace)
QtTest.QTest.mouseClick(self.window.multilayers.btGetCapabilities, QtCore.Qt.LeftButton)
qm_critical.assert_called_once()
assert self.view.draw_image.call_count == 0
assert self.view.draw_legend.call_count == 0
assert self.view.draw_metadata.call_count == 0
QtTest.QTest.keyClick(self.window.multilayers.cbWMS_URL, ord(str(self.port)[3]))
QtTest.QTest.keyClick(self.window.multilayers.cbWMS_URL, QtCore.Qt.Key_Slash)
QtWidgets.QApplication.processEvents()
QtTest.QTest.mouseClick(self.window.multilayers.btGetCapabilities, QtCore.Qt.LeftButton)
QtWidgets.QApplication.processEvents()
wait_until_signal(self.window.cpdlg.canceled)

QtTest.QTest.mouseClick(self.window.btGetMap, QtCore.Qt.LeftButton)
QtWidgets.QApplication.processEvents()
wait_until_signal(self.window.image_displayed)
with qtbot.wait_signal(self.window.cpdlg.canceled):
QtTest.QTest.keyClick(self.window.multilayers.cbWMS_URL, ord(str(self.port)[-1]))
QtTest.QTest.keyClick(self.window.multilayers.cbWMS_URL, QtCore.Qt.Key_Slash)
QtTest.QTest.mouseClick(self.window.multilayers.btGetCapabilities, QtCore.Qt.LeftButton)

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

assert self.view.draw_image.call_count == 1
assert self.view.draw_legend.call_count == 1
Expand Down Expand Up @@ -299,7 +295,6 @@ def test_multilayer_handling(self):
assert self.view.draw_legend.call_count == 1
assert self.view.draw_metadata.call_count == 1

@pytest.mark.skip("Fails testing reverse order")
def test_filter_handling(self):
self.query_server(self.url)
server = self.window.multilayers.listLayers.findItems(f"{self.url}/",
Expand All @@ -309,13 +304,13 @@ def test_filter_handling(self):
assert "header" in self.window.multilayers.layers[f"{self.url}/"]
assert "wms" in self.window.multilayers.layers[f"{self.url}/"]

starts_at = 40 * self.window.multilayers.scale
starts_at = int(40 * self.window.multilayers.scale)
icon_start_fav = starts_at + 3
if self.window.multilayers.cbMultilayering.isChecked():
checkbox_width = round(self.window.multilayers.height * 0.75)
icon_start_fav += checkbox_width + 6

starts_at = 20 * self.window.multilayers.scale
starts_at = int(20 * self.window.multilayers.scale)
icon_start_del = starts_at + 3

# Check layer filter is working
Expand Down Expand Up @@ -442,19 +437,17 @@ def setup(self, qapp):
self._teardown()

def test_server_getmap(self, qtbot):
pytest.skip("unknown problem")
"""
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.window.image_displayed):
QtTest.QTest.mouseClick(self.window.btGetMap, QtCore.Qt.LeftButton)

assert self.view.draw_image.call_count == 1
assert self.view.draw_legend.call_count == 1
assert self.view.draw_metadata.call_count == 1

@pytest.mark.skip("IndexError: list index out of range")
def test_multilayer_drawing(self):
"""
assert that drawing a layer through code doesn't fail for vsec
Expand Down
3 changes: 0 additions & 3 deletions tests/_test_mswms/test_mss_plot_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def test_VS_ProbabilityOfWCBStyle_01(self):
assert noframe != img

def test_VS_LagrantoTrajStyle_PL_01(self):
pytest.skip("data not available")
img = self.plot(mpl_vsec_styles.VS_LagrantoTrajStyle_PL_01(driver=self.vsec))
assert img is not None
noframe = self.plot(mpl_vsec_styles.VS_LagrantoTrajStyle_PL_01(driver=self.vsec), noframe=True)
Expand All @@ -199,7 +198,6 @@ def test_VS_EMACEyja_Style_01(self):
assert noframe != img

def test_VS_gallery_template(self):
pytest.skip('Test can be biased. In pytest-reverse when there is not a plot_examples it can''t import')
# ToDo Test Data have to be written to a random tmp dir and that may become purged afterwards
templates_location = os.path.join(mslib.mswms.gallery_builder.DOCS_LOCATION, "plot_examples")
sys.path.append(templates_location)
Expand Down Expand Up @@ -504,7 +502,6 @@ def test_HS_Meteosat_BT108_01(self):
assert noframe != img

def test_HS_gallery_template(self):
pytest.skip('Test can be biased. In pytest-reverse when there is not a plot_examples it can''t import')
# ToDo Test Data have to be written to a random tmp dir and that may become purged afterwards
templates_location = os.path.join(mslib.mswms.gallery_builder.DOCS_LOCATION, "plot_examples")
sys.path.append(templates_location)
Expand Down
16 changes: 0 additions & 16 deletions tests/_test_utils/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ def test_existing_empty_config_file(self):
"""
on a user defined empty msui_settings_json this test should return the default value for num_labels
"""
if not fs.open_fs(MSUI_CONFIG_PATH).exists("msui_settings.json"):
pytest.skip('undefined test msui_settings.json')
with fs.open_fs(MSUI_CONFIG_PATH) as file_dir:
file_content = file_dir.readtext("msui_settings.json")
assert ":" not in file_content
Expand All @@ -143,8 +141,6 @@ def test_existing_config_file_different_parameters(self):
on a user defined msui_settings_json without a defined num_labels this test should return its default value
"""
create_msui_settings_file('{"num_interpolation_points": 20 }')
if not fs.open_fs(MSUI_CONFIG_PATH).exists("msui_settings.json"):
pytest.skip('undefined test msui_settings.json')
with fs.open_fs(MSUI_CONFIG_PATH) as file_dir:
file_content = file_dir.readtext("msui_settings.json")
assert "num_labels" not in file_content
Expand All @@ -168,8 +164,6 @@ def test_existing_config_file_defined_parameters(self):
on a user defined msui_settings_json without a defined num_labels this test should return its default value
"""
create_msui_settings_file('{"num_interpolation_points": 201, "num_labels": 10 }')
if not fs.open_fs(MSUI_CONFIG_PATH).exists("msui_settings.json"):
pytest.skip('undefined test msui_settings.json')
with fs.open_fs(MSUI_CONFIG_PATH) as file_dir:
file_content = file_dir.readtext("msui_settings.json")
assert "num_labels" in file_content
Expand All @@ -187,8 +181,6 @@ def test_existing_config_file_invalid_parameters(self):
on a user defined msui_settings_json with duplicate and empty keys should raise FatalUserError
"""
create_msui_settings_file('{"num_interpolation_points": 201, "num_interpolation_points": 10 }')
if not fs.open_fs(MSUI_CONFIG_PATH).exists("msui_settings.json"):
pytest.skip('undefined test msui_settings.json')
with fs.open_fs(MSUI_CONFIG_PATH) as file_dir:
file_content = file_dir.readtext("msui_settings.json")
assert "num_interpolation_points" in file_content
Expand All @@ -197,8 +189,6 @@ def test_existing_config_file_invalid_parameters(self):
read_config_file(path=config_file)

create_msui_settings_file('{"": 201, "num_labels": 10 }')
if not fs.open_fs(MSUI_CONFIG_PATH).exists("msui_settings.json"):
pytest.skip('undefined test msui_settings.json')
with fs.open_fs(MSUI_CONFIG_PATH) as file_dir:
file_content = file_dir.readtext("msui_settings.json")
assert "num_labels" in file_content
Expand All @@ -209,8 +199,6 @@ def test_modify_config_file_with_empty_parameters(self):
"""
Test to check if modify_config_file properly stores a key-value pair in an empty config file
"""
if not fs.open_fs(MSUI_CONFIG_PATH).exists("msui_settings.json"):
pytest.skip('undefined test msui_settings.json')
data_to_save_in_config_file = {
"num_labels": 20
}
Expand All @@ -225,8 +213,6 @@ def test_modify_config_file_with_existing_parameters(self):
Test to check if modify_config_file properly modifies a key-value pair in the config file
"""
create_msui_settings_file('{"num_labels": 14}')
if not fs.open_fs(MSUI_CONFIG_PATH).exists("msui_settings.json"):
pytest.skip('undefined test msui_settings.json')
data_to_save_in_config_file = {
"num_labels": 20
}
Expand All @@ -240,8 +226,6 @@ def test_modify_config_file_with_invalid_parameters(self):
"""
Test to check if modify_config_file raises a KeyError when a key is empty
"""
if not fs.open_fs(MSUI_CONFIG_PATH).exists("msui_settings.json"):
pytest.skip('undefined test msui_settings.json')
data_to_save_in_config_file = {
"": "sree",
"num_labels": "20"
Expand Down

0 comments on commit 579e577

Please sign in to comment.