Skip to content

Commit

Permalink
Remove unnecessary skips
Browse files Browse the repository at this point in the history
  • Loading branch information
matrss committed Jan 29, 2024
1 parent ed7db38 commit 15965c6
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 68 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 @@ -386,7 +386,6 @@ def test_import_file(self, mockbox, 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 @@ -405,10 +404,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 @@ -425,7 +422,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 @@ -458,7 +457,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
1 change: 0 additions & 1 deletion tests/_test_msui/test_mscolab_save_merge_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from PyQt5 import QtCore, QtTest, QtWidgets


@pytest.mark.skip("Uses QTimer, which can break other unrelated tests")
@pytest.mark.skipif(os.name == "nt",
reason="multiprocessing needs currently start_method fork")
class Test_Save_Merge_Points(Test_Mscolab_Merge_Waypoints):
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
16 changes: 7 additions & 9 deletions tests/_test_msui/test_msui.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ def test_open_about(self, mockbox):

@mock.patch("PyQt5.QtWidgets.QMessageBox")
def test_open_config(self, mockbox):
pytest.skip("To be done")
self.window.actionConfigurationEditor.trigger()
self.window.actionConfiguration.trigger()
QtWidgets.QApplication.processEvents()
self.window.config_editor.close()
assert mockbox.critical.call_count == 0
Expand Down Expand Up @@ -315,22 +314,21 @@ 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("PyQt5.QtWidgets.QMessageBox")
@mock.patch("mslib.msui.msui_mainwindow.config_loader", return_value=export_plugins)
def test_add_plugins(self, mockopen, mockbox):
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
assert mockbox.critical.call_count == 0

self.window.remove_plugins()
Expand All @@ -350,8 +348,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.critical")
@mock.patch("PyQt5.QtWidgets.QMessageBox.warning", 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 @@ -129,7 +129,6 @@ def test_options(self, mockdlg, mockbox):
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")
@mock.patch("PyQt5.QtWidgets.QMessageBox")
def test_insert_point(self, mockbox):
"""
Expand Down
47 changes: 17 additions & 30 deletions tests/_test_msui/test_wms_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,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 @@ -239,39 +238,30 @@ def test_server_getmap_cached(self, mockbox, qtbot):
assert self.view.draw_legend.call_count == 1
assert self.view.draw_metadata.call_count == 1

@pytest.mark.skip("needs a review")
@mock.patch("PyQt5.QtWidgets.QMessageBox")
def test_server_service_cache(self, mockbox):
def test_server_service_cache(self, qtbot):
"""
assert that changing between servers still allows image retrieval
"""
self.query_server(self.url)
assert mockbox.critical.call_count == 0

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)
assert mockbox.critical.call_count == 1
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
mockbox.reset_mock()
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)
assert mockbox.critical.call_count == 0

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 mockbox.critical.call_count == 0
assert self.view.draw_image.call_count == 1
assert self.view.draw_legend.call_count == 1
assert self.view.draw_metadata.call_count == 1
Expand Down Expand Up @@ -320,7 +310,6 @@ def test_multilayer_handling(self, mockbox):
assert self.view.draw_legend.call_count == 1
assert self.view.draw_metadata.call_count == 1

@pytest.mark.skip("Fails testing reverse order")
@mock.patch("PyQt5.QtWidgets.QMessageBox")
def test_filter_handling(self, mockbox):
self.query_server(self.url)
Expand All @@ -331,13 +320,13 @@ def test_filter_handling(self, mockbox):
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 @@ -474,12 +463,11 @@ def setup(self, qapp):

@mock.patch("PyQt5.QtWidgets.QMessageBox")
def test_server_getmap(self, mockbox, 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 mockbox.critical.call_count == 0
Expand All @@ -488,7 +476,6 @@ def test_server_getmap(self, mockbox, qtbot):
assert self.view.draw_metadata.call_count == 1
self.view.reset_mock()

@pytest.mark.skip("IndexError: list index out of range")
@mock.patch("PyQt5.QtWidgets.QMessageBox")
def test_multilayer_drawing(self, mockbox):
"""
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 15965c6

Please sign in to comment.