Пример #1
0
    def test_that_gets_pre_processing_options_are_valid_and_other_options_are_empty(
            self):
        # Arrange
        presenter = MainPresenter(SANSFacility.ISIS)
        content = "# MANTID_BATCH_FILE add more text here\n" \
                  "sample_sans,SANS2D00022024,sample_trans,SANS2D00022048," \
                  "sample_direct_beam,SANS2D00022048,output_as,test_file\n" \
                  "sample_sans,SANS2D00022024,output_as,test_file2\n"
        batch_file_path = save_to_csv(content)
        user_file_path = create_user_file(sample_user_file)
        view = create_mock_view2(user_file_path, batch_file_path)
        presenter.set_view(view)

        # Act
        pre_processing_options = presenter.getProcessingOptions()

        # Assert
        expected = {'UseOptimizations':'1','OutputMode':'PublishToADS','PlotResults':'1', \
                    'OutputGraph':'SANS-Latest'}
        self.assertEqual(expected, pre_processing_options)
        self.assertFalse(presenter.getPreprocessingOptions())
        self.assertFalse(presenter.getPostprocessingOptionsAsString())

        # Clean up
        remove_file(sample_user_file)
        remove_file(user_file_path)
Пример #2
0
    def test_that_gets_pre_processing_options_are_valid_and_other_options_are_empty(self):
        # Arrange
        presenter = MainPresenter(SANSFacility.ISIS)
        content = "# MANTID_BATCH_FILE add more text here\n" \
                  "sample_sans,SANS2D00022024,sample_trans,SANS2D00022048," \
                  "sample_direct_beam,SANS2D00022048,output_as,test_file\n" \
                  "sample_sans,SANS2D00022024,output_as,test_file2\n"
        batch_file_path = save_to_csv(content)
        user_file_path = create_user_file(sample_user_file)
        view = create_mock_view2(user_file_path, batch_file_path)
        presenter.set_view(view)

        # Act
        pre_processing_options = presenter.getProcessingOptions()

        # Assert
        expected = {'UseOptimizations':'1','OutputMode':'PublishToADS','PlotResults':'1', \
                    'OutputGraph':'SANS-Latest'}
        self.assertEqual(expected, pre_processing_options)
        self.assertFalse(presenter.getPreprocessingOptions())
        self.assertFalse(presenter.getPostprocessingOptionsAsString())

        # Clean up
        remove_file(sample_user_file)
        remove_file(user_file_path)
Пример #3
0
 def _get_files_and_mock_presenter(content):
     batch_file_path = save_to_csv(content)
     user_file_path = create_user_file(sample_user_file)
     view, _, _ = create_mock_view(user_file_path, batch_file_path)
     # We just use the sample_user_file since it exists.
     view.get_mask_file = mock.MagicMock(return_value=user_file_path)
     presenter = RunTabPresenter(SANSFacility.ISIS)
     presenter.set_view(view)
     return batch_file_path, user_file_path, presenter, view
Пример #4
0
    def test_that_returns_none_when_index_does_not_exist(self):
        # Arrange
        batch_file_path = save_to_csv(BATCH_FILE_TEST_CONTENT_2)
        user_file_path = create_user_file(sample_user_file)
        view, _, _ = create_mock_view(user_file_path, batch_file_path)
        presenter = RunTabPresenter(SANSFacility.ISIS)
        presenter.set_view(view)
        presenter.on_user_file_load()
        presenter.on_batch_file_load()

        # Act
        state = presenter.get_state_for_row(3)

        # Assert
        self.assertTrue(state is None)

        # Clean up
        remove_file(batch_file_path)
        remove_file(user_file_path)