def test_retieves_file_information_and_passes_to_callback(self):
        create_file_information('LOQ74044', self.error_callback, self.success_callback, self.work_handler, 0)
        self.work_handler.wait_for_done()
        self.qApp.processEvents()

        self.assertEqual(self.success_callback.call_count, 1)
        self.assertEqual(self.error_callback.call_count, 0)
    def test_retieves_file_information_and_passes_to_callback(self):
        create_file_information('LOQ74044', self.error_callback, self.success_callback, self.work_handler, 0)
        self.work_handler.wait_for_done()
        self.qApp.processEvents()

        self.assertEqual(self.success_callback.call_count, 1)
        self.assertEqual(self.error_callback.call_count, 0)
    def test_that_retrieved_file_information_is_correct(self):
        create_file_information('LOQ74044', self.error_callback, self.success_callback, self.work_handler, 0)
        self.work_handler.wait_for_done()
        self.qApp.processEvents()

        file_information = self.success_callback.call_args[0][0]
        self.assertEqual(file_information.is_event_mode(), False)
        self.assertEqual(file_information.get_run_number(), 74044)
        self.assertEqual(file_information.get_thickness(), 1.0)
    def test_that_retrieved_file_information_is_correct(self):
        create_file_information('LOQ74044', self.error_callback, self.success_callback, self.work_handler, 0)
        self.work_handler.wait_for_done()
        self.qApp.processEvents()

        file_information = self.success_callback.call_args[0][0]
        self.assertEqual(file_information.is_event_mode(), False)
        self.assertEqual(file_information.get_run_number(), 74044)
        self.assertEqual(file_information.get_thickness(), 1.0)
    def test_that_error_callback_is_called_on_error_with_correct_message(self, file_information_factory_mock):
        file_information_factory_instance = mock.MagicMock()
        file_information_factory_instance.create_sans_file_information.side_effect = RuntimeError('File Error')
        file_information_factory_mock.return_value = file_information_factory_instance

        create_file_information('LOQ74044', self.error_callback, self.success_callback, self.work_handler, 0)
        self.work_handler.wait_for_done()
        self.qApp.processEvents()

        self.success_callback.assert_called_once_with(None)
        self.assertEqual(self.error_callback.call_count, 1)
        self.assertEqual(str(self.error_callback.call_args[0][0][1]), 'File Error')
    def test_that_multiple_threading_calls_at_once_are_handled_cleanly(self):
        create_file_information('LOQ74044', self.error_callback, self.success_callback, self.work_handler, 0)
        create_file_information('LOQ74044', self.error_callback, self.success_callback_1, self.work_handler, 0)
        create_file_information('LOQ74044', self.error_callback, self.success_callback_1, self.work_handler, 1)
        create_file_information('LOQ74044', self.error_callback, self.success_callback_1, self.work_handler, 0)
        create_file_information('LOQ74044', self.error_callback, self.success_callback_1, self.work_handler, 2)
        self.work_handler.wait_for_done()
        self.qApp.processEvents()

        self.assertEqual(self.success_callback.call_count, 0)
        self.assertEqual(self.success_callback_1.call_count, 3)
        self.assertEqual(self.error_callback.call_count, 0)
    def test_that_error_callback_is_called_on_error_with_correct_message(self, file_information_factory_mock):
        file_information_factory_instance = mock.MagicMock()
        file_information_factory_instance.create_sans_file_information.side_effect = RuntimeError('File Error')
        file_information_factory_mock.return_value = file_information_factory_instance

        create_file_information('LOQ74044', self.error_callback, self.success_callback, self.work_handler, 0)
        self.work_handler.wait_for_done()
        self.qApp.processEvents()

        self.success_callback.assert_called_once_with(None)
        self.assertEqual(self.error_callback.call_count, 1)
        self.assertEqual(str(self.error_callback.call_args[0][0][1]), 'File Error')
    def test_that_multiple_threading_calls_at_once_are_handled_cleanly(self):
        create_file_information('LOQ74044', self.error_callback, self.success_callback, self.work_handler, 0)
        create_file_information('LOQ74044', self.error_callback, self.success_callback_1, self.work_handler, 0)
        create_file_information('LOQ74044', self.error_callback, self.success_callback_1, self.work_handler, 1)
        create_file_information('LOQ74044', self.error_callback, self.success_callback_1, self.work_handler, 0)
        create_file_information('LOQ74044', self.error_callback, self.success_callback_1, self.work_handler, 2)
        self.work_handler.wait_for_done()
        self.qApp.processEvents()

        self.assertEqual(self.success_callback.call_count, 0)
        self.assertEqual(self.success_callback_1.call_count, 3)
        self.assertEqual(self.error_callback.call_count, 0)
Ejemplo n.º 9
0
    def get_thickness_for_rows(self, rows=None):
        """
        Read in the sample thickness for the given rows from the file and set it in the table.
        :param rows: list of table rows
        """
        if not rows:
            rows = range(len(self._table_entries))
        for row in rows:
            entry = self._table_entries[row]
            if entry.is_empty():
                continue
            entry.file_finding = True
            success_callback = functools.partial(self.update_thickness_from_file_information, entry.id)

            error_callback = functools.partial(self.failure_handler, entry.id)
            create_file_information(entry.sample_scatter, error_callback, success_callback,
                                    self.work_handler, entry.id)
Ejemplo n.º 10
0
    def get_thickness_for_rows(self, rows=None):
        """
        Read in the sample thickness for the given rows from the file and set it in the table.
        :param rows: list of table rows
        """
        if not rows:
            rows = range(len(self._table_entries))
        for row in rows:
            entry = self._table_entries[row]
            if entry.is_empty():
                continue
            entry.file_finding = True
            success_callback = functools.partial(
                self.update_thickness_from_file_information, entry.id)

            error_callback = functools.partial(self.failure_handler, entry.id)
            create_file_information(entry.sample_scatter, error_callback,
                                    success_callback, self.work_handler,
                                    entry.id)