Esempio n. 1
0
    def test_on_cut_rows_requested_updates_clipboard(self):
        self._mock_view.get_selected_rows.return_value = [0]
        expected_clipboard = mock.NonCallableMock()
        self._mock_table.get_row.return_value = expected_clipboard

        self.presenter.on_cut_rows_requested()

        self.assertTrue(expected_clipboard in self.presenter._clipboard)
Esempio n. 2
0
    def test_that_can_get_state_for_index_if_index_exists(self):
        state_key = mock.NonCallableMock()
        self._mock_table.get_row.return_value = state_key
        expected_states, expected_errs = {state_key: "state"}, None
        self.presenter.get_states = mock.Mock(return_value=(expected_states,
                                                            expected_errs))
        self.presenter.sans_logger = mock.Mock()

        state = self.presenter.get_state_for_row(0)

        self.assertEqual(expected_states[state_key], state)
Esempio n. 3
0
    def test_on_paste_rows_requested_replaces_row_if_one_row_is_selected(self):
        pos = [1]
        self._mock_view.get_selected_rows.return_value = pos

        test_row_0 = mock.NonCallableMock()
        self.presenter._clipboard = [test_row_0]
        self.presenter.update_view_from_table_model = mock.MagicMock()

        self.presenter.on_paste_rows_requested()

        self.presenter.update_view_from_table_model.assert_called_with()
        self._mock_table.replace_table_entries.assert_called_with(
            pos, [test_row_0])
Esempio n. 4
0
    def test_on_paste_rows_requested_replaces_first_row_and_removes_rest_if_multiple_rows_selected(
            self):
        expected_pos = [0, 2]
        self._mock_view.get_selected_rows.return_value = expected_pos

        expected = mock.NonCallableMock()
        self.presenter._clipboard = [expected]
        self.presenter.update_view_from_table_model = mock.MagicMock()

        self.presenter.on_paste_rows_requested()

        self.presenter.update_view_from_table_model.assert_called_with()
        self._mock_table.replace_table_entries.assert_called_with(
            expected_pos, [expected])
Esempio n. 5
0
    def test_on_paste_rows_requested_appends_new_row_if_no_row_selected(self):
        self._mock_view.get_selected_rows.return_value = []
        pos = 101
        self._mock_table.get_number_of_rows.return_value = pos

        expected = mock.NonCallableMock()
        self.presenter._clipboard = [expected]
        self.presenter.update_view_from_table_model = mock.MagicMock()

        self.presenter.on_paste_rows_requested()

        self.presenter.update_view_from_table_model.assert_called_with()
        self._mock_table.replace_table_entries.assert_called_with([pos],
                                                                  [expected])
Esempio n. 6
0
    def test_valid_key_accepted(self):
        expected_valid_examples = [{
            "instrument": {
                "name": mock.NonCallableMock()
            }
        }, {
            "instrument": {
                "configuration": {
                    "sample_offset": 1.0
                }
            }
        }]

        for i in expected_valid_examples:
            obj = TomlSchemaV1Validator(i)
            self.assertIsNone(obj.validate())
Esempio n. 7
0
    def test_on_data_changed_updates_table_model(self):
        self.presenter._beam_centre_presenter = mock.Mock()
        self.presenter._masking_table_presenter = mock.Mock()

        expected_new_entry = mock.NonCallableMock()
        self._mock_table.get_all_rows.return_value = [expected_new_entry]

        self.presenter.on_data_changed(0, expected_new_entry)
        self._mock_table.replace_table_entry.assert_called_with(
            0, expected_new_entry)

        self.presenter._beam_centre_presenter.on_update_rows.assert_called_with(
        )
        self.presenter._masking_table_presenter.on_update_rows.assert_called_with(
        )
        self.presenter.update_view_from_table_model.assert_called_with()
Esempio n. 8
0
    def test_on_data_changed_calls_update_rows(self):
        batch_file_path, user_file_path, _ = self._get_files_and_mock_presenter(
            BATCH_FILE_TEST_CONTENT_1)
        self.presenter._masking_table_presenter = mock.MagicMock()
        self.presenter._table_model.subscribe_to_model_changes(
            self.presenter._masking_table_presenter)
        self.presenter._beam_centre_presenter = mock.MagicMock()
        self.presenter._table_model.subscribe_to_model_changes(
            self.presenter._beam_centre_presenter)

        updated_entries = mock.NonCallableMock()
        self.presenter.on_data_changed(0, updated_entries)

        self.presenter._masking_table_presenter.on_update_rows.assert_called_with(
        )
        self.presenter._beam_centre_presenter.on_update_rows.assert_called_with(
        )
        self.presenter.update_view_from_table_model.assert_called_with()