def test_that_it_adds_nothing_when_empty_list_is_passed_in(self): pms = PropertyManagerService() number_of_elements_on_pmds_after = len( PropertyManagerDataService.getObjectNames()) pms.add_states_to_pmds({}) self.assertEqual(number_of_elements_on_pmds_after, 0) self._remove_all_property_managers()
def test_that_add_states_to_pmds(self): self.assertEqual(len(PropertyManagerDataService.getObjectNames()), 0) states = {0: get_example_state(), 1: get_example_state()} pms = PropertyManagerService() pms.add_states_to_pmds(states) self.assertEqual(len(PropertyManagerDataService.getObjectNames()), 2) self._remove_all_property_managers()
def test_that_add_states_to_pmds(self): self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 0) states = {0: get_example_state(), 1: get_example_state()} pms = PropertyManagerService() pms.add_states_to_pmds(states) self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 2) self._remove_all_property_managers()
def on_processed_clicked(self): """ Prepares the batch reduction. 0. Validate rows and create dummy workspace if it does not exist 1. Sets up the states 2. Adds a dummy input workspace 3. Adds row index information """ try: self.sans_logger.information("Starting processing of batch table.") # 0. Validate rows self._create_dummy_input_workspace() self._validate_rows() # 1. Set up the states and convert them into property managers states = self.get_states() if not states: raise RuntimeError( "There seems to have been an issue with setting the states. Make sure that a user file" " has been loaded") property_manager_service = PropertyManagerService() property_manager_service.add_states_to_pmds(states) # 2. Add dummy input workspace to Options column self._remove_dummy_workspaces_and_row_index() self._set_dummy_workspace() # 3. Add dummy row index to Options column self._set_indices() except Exception as e: self._view.halt_process_flag() self.sans_logger.error("Process halted due to: {}".format(str(e)))
def test_that_removes_sans_property_managers_from_pmds(self): self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 0) states = {0: get_example_state(), 1: get_example_state()} pms = PropertyManagerService() pms.add_states_to_pmds(states) pms.remove_sans_property_managers() self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 0) self._remove_all_property_managers()
def test_that_can_retrieve_states_from_pmds(self): self.assertEqual(len(PropertyManagerDataService.getObjectNames()), 0) states = {0: get_example_state(), 1: get_example_state()} pms = PropertyManagerService() pms.add_states_to_pmds(states) retrieved_states = pms.get_states_from_pmds() self.assertEqual(len(retrieved_states), 2) self.assertTrue(isinstance(retrieved_states[0], type(states[0]))) self.assertEqual(len(PropertyManagerDataService.getObjectNames()), 2) self._remove_all_property_managers()
def test_that_can_retrieve_states_from_pmds(self): self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 0) states = {0: get_example_state(), 1: get_example_state()} pms = PropertyManagerService() pms.add_states_to_pmds(states) retrieved_states = pms.get_states_from_pmds() self.assertTrue(len(retrieved_states) == 2) self.assertTrue(isinstance(retrieved_states[0], type(states[0]))) self.assertTrue(len(PropertyManagerDataService.getObjectNames()) == 2) self._remove_all_property_managers()
def test_that_it_adds_nothing_when_empty_list_is_passed_in(self): pms = PropertyManagerService() number_of_elements_on_pmds_after = len(PropertyManagerDataService.getObjectNames()) pms.add_states_to_pmds({}) self.assertTrue(number_of_elements_on_pmds_after == 0) self._remove_all_property_managers()