def test_tabs_model_delete_tab():
    test_model = models.TabsModel()
    new_tab = tabs.TabData("My tab", models.WorkflowListModel2())
    # new_tab.tab_name =
    test_model += new_tab

    second_new_tab = tabs.TabData("second new tab", models.WorkflowListModel2())
    test_model += second_new_tab
    assert test_model.rowCount() == 2

    test_model -= second_new_tab
    assert test_model.rowCount() == 1
def test_tabs_model_delete_all_tabs():
    test_model = models.TabsModel()
    first_new_tab = tabs.TabData("My tab", models.WorkflowListModel2())
    test_model += first_new_tab

    second_new_tab = tabs.TabData("second new tab", models.WorkflowListModel2())
    test_model += second_new_tab
    assert test_model.rowCount() == 2

    test_model -= second_new_tab
    assert test_model.rowCount() == 1

    test_model -= first_new_tab
    assert test_model.rowCount() == 0
Exemple #3
0
    def _create_new_tab(self) -> None:
        while True:
            new_tab_name: str
            accepted: bool
            new_tab_name, accepted = QtWidgets.QInputDialog.getText(
                self.parentWidget(), "Create New Tab", "Tab name")

            # The user cancelled
            if not accepted:
                return

            if new_tab_name in self.tabs_model:
                message = f"Tab named \"{new_tab_name}\" already exists."
                error = QtWidgets.QMessageBox(self)
                error.setText(message)
                error.setWindowTitle("Unable to Create New Tab")
                error.setIcon(QtWidgets.QMessageBox.Critical)
                error.exec()
                continue

            new_tab = tabs.TabData(new_tab_name, models.WorkflowListModel2())
            self.tabs_model.add_tab(new_tab)
            new_index = self.selected_tab_combo_box.findText(new_tab_name)
            self.selected_tab_combo_box.setCurrentIndex(new_index)
            return
Exemple #4
0
 def test_write_tabs_yaml(self, ):
     sample_tab_data = [
         tabs.TabData("dummy_tab", MagicMock())
     ]
     with patch('speedwagon.tabs.open', mock.mock_open()) as m:
         tabs.write_tabs_yaml("tabs.yml", sample_tab_data)
         assert m.called is True
     handle = m()
     handle.write.assert_has_calls([call('dummy_tab')])
Exemple #5
0
 def test_tabs_model_iadd_tab(self):
     test_model = models.TabsModel()
     new_tab = tabs.TabData("My tab", models.WorkflowListModel2())
     test_model += new_tab
     assert test_model.rowCount() == 1