Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Send message to console when deleting a dataset #260

Merged
merged 2 commits into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions gwhat/projet/manager_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ def del_current_wldset(self):
self.update_wldsets()
self.update_wldset_info()
self.wldset_changed()
self.sig_new_console_msg.emit((
"<font color=black>Water level dataset <i>{}</i> deleted "
"successfully.</font>").format(dsetname))

# ---- WX Dataset
@property
Expand Down Expand Up @@ -387,6 +390,9 @@ def del_current_wxdset(self):
self.update_wxdsets()
self.update_wxdset_info()
self.wxdset_changed()
self.sig_new_console_msg.emit((
"<font color=black>Weather dataset <i>{}</i> deleted "
"successfully.</font>").format(dsetname))

def get_current_wxdset(self):
"""Return the currently selected weather dataset dataframe."""
Expand Down
12 changes: 8 additions & 4 deletions gwhat/projet/tests/test_manager_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,15 @@ def test_delete_weather_data(datamanager, mocker, qtbot):
# 'Don't show this message again' option and answer Yes.
mock_exec_.return_value = QMessageBox.Yes
mocker.patch.object(QCheckBox, 'isChecked', return_value=True)
qtbot.mouseClick(datamanager.btn_del_wxdset, Qt.LeftButton)
with qtbot.waitSignal(datamanager.sig_new_console_msg, raising=True):
qtbot.mouseClick(datamanager.btn_del_wxdset, Qt.LeftButton)
assert datamanager.wxdataset_count() == 1
assert datamanager._confirm_before_deleting_dset is False
assert mock_exec_.call_count == 2

# Click to delete the current weather dataset.
qtbot.mouseClick(datamanager.btn_del_wxdset, Qt.LeftButton)
with qtbot.waitSignal(datamanager.sig_new_console_msg, raising=True):
qtbot.mouseClick(datamanager.btn_del_wxdset, Qt.LeftButton)
assert datamanager.wxdataset_count() == 0
assert datamanager._confirm_before_deleting_dset is False
assert mock_exec_.call_count == 2
Expand Down Expand Up @@ -157,13 +159,15 @@ def test_delete_waterlevel_data(datamanager, mocker, qtbot):
# 'Don't show this message again' option and answer Yes.
mock_exec_.return_value = QMessageBox.Yes
mocker.patch.object(QCheckBox, 'isChecked', return_value=True)
qtbot.mouseClick(datamanager.btn_del_wldset, Qt.LeftButton)
with qtbot.waitSignal(datamanager.sig_new_console_msg, raising=True):
qtbot.mouseClick(datamanager.btn_del_wldset, Qt.LeftButton)
assert datamanager.wldataset_count() == 1
assert datamanager._confirm_before_deleting_dset is False
assert mock_exec_.call_count == 2

# Click to delete the current weather dataset.
qtbot.mouseClick(datamanager.btn_del_wldset, Qt.LeftButton)
with qtbot.waitSignal(datamanager.sig_new_console_msg, raising=True):
qtbot.mouseClick(datamanager.btn_del_wldset, Qt.LeftButton)
assert datamanager.wldataset_count() == 0
assert datamanager._confirm_before_deleting_dset is False
assert mock_exec_.call_count == 2
Expand Down