예제 #1
0
 def test_get_config(self):
     """Verify returning the application's configuration"""
     expected_configuration = config.Configure(pathfinder.config_path()).config
     expected_configuration.read(pathfinder.config_path())
     returned_configuration = model.get_config().config
     returned_configuration.read(pathfinder.config_path())
     for section in expected_configuration.sections():
         self.assertListEqual(expected_configuration.items(section), returned_configuration.items(section))
예제 #2
0
 def test_get_config(self):
     """Verify returning the application's configuration"""
     expected_configuration = config.Configure(
         pathfinder.config_path()).config
     expected_configuration.read(pathfinder.config_path())
     returned_configuration = model.get_config().config
     returned_configuration.read(pathfinder.config_path())
     for section in expected_configuration.sections():
         self.assertListEqual(expected_configuration.items(section),
                              returned_configuration.items(section))
예제 #3
0
 def test_get_size(self):
     """Verify returning the size of the main app window set in config"""
     cfg = config.Configure(pathfinder.config_path())
     str_win_size = cfg.get_app_option_list("Window Size")
     expected_win_size = [300, 600]
     if str_win_size is not None:
         expected_win_size = [int(dimsize) for dimsize in str_win_size]
     self.assertListEqual(expected_win_size, self.model.get_window_size())
예제 #4
0
 def test_get_coords(self):
     """Verify returning the UL corner of the main app window set in config"""
     cfg = config.Configure(pathfinder.config_path())
     str_coords = cfg.get_app_option_list("Coordinates")
     expected_coords = (0, 0)
     if str_coords is not None:
         expected_coords = [int(coord) for coord in str_coords]
     self.assertListEqual(expected_coords, self.model.get_coords())
예제 #5
0
 def test_set_preview_state(self):
     """Verify setting the current setting for displaying plot thumbnails"""
     cfg = config.Configure(pathfinder.config_path())
     original_preview_state = cfg.get_app_option_boolean("Enable Preview")
     new_preview_state = not original_preview_state
     self.assertEqual(original_preview_state, self.model.get_preview_state())
     self.model.set_preview_state(new_preview_state)
     self.assertEqual(new_preview_state, self.model.get_preview_state())
     self.model.set_preview_state(original_preview_state)
예제 #6
0
 def setUp(self):
     self.sample_data = np.array(self.random_data())
     self.sample_data_basename = "sample.dat"
     self.sample_data_file = os.path.join(os.path.dirname(__file__),
                                          self.sample_data_basename)
     with h5py.File(self.sample_data_file, 'w') as fidout:
         fidout.create_dataset(self.sample_data_basename, data=self.sample_data)
     self.mock_controller = ""
     self.model = model.MainModel(self.mock_controller)
     cfg = config.Configure(pathfinder.config_path())
     self.original_loglevel = cfg.get_app_option("log level")
예제 #7
0
 def test_get_loglevel(self):
     """Verify returning the log level from config"""
     cfg = config.Configure(pathfinder.config_path())
     log_level = cfg.get_app_option("log level")
     available_log_levels = {'debug': logging.DEBUG,
                             'info': logging.INFO,
                             'warning': logging.WARNING,
                             'error': logging.ERROR,
                             'critical': logging.CRITICAL}
     log_level = available_log_levels.get(log_level, logging.WARNING)
     self.assertEqual(log_level, model.get_loglevel())
예제 #8
0
 def test_set_size(self):
     """Verify setting the size of the main app window in config"""
     cfg = config.Configure(pathfinder.config_path())
     str_win_size = cfg.get_app_option_list("Window Size")
     original_win_size = [300, 600]
     if str_win_size is not None:
         original_win_size = [int(dimsize) for dimsize in str_win_size]
     self.assertListEqual(original_win_size, self.model.get_window_size())
     new_win_size = [800, 1024]
     self.model.set_window_size(new_win_size)
     self.assertListEqual(new_win_size, self.model.get_window_size())
     self.model.set_window_size(original_win_size)
예제 #9
0
 def test_set_loglevel(self):
     """Verify setting the log level in config"""
     cfg = config.Configure(pathfinder.config_path())
     log_levels = ['debug', 'info', 'warning', 'error', 'critical', None, 'abc']
     acceptable_log_levels = {'debug': logging.DEBUG,
                              'info': logging.INFO,
                              'warning': logging.WARNING,
                              'error': logging.ERROR,
                              'critical': logging.CRITICAL}
     for level in log_levels:
         model.set_loglevel(level)
         if level in acceptable_log_levels:
             self.assertEqual(acceptable_log_levels[level], model.get_loglevel())
예제 #10
0
 def test_set_coords(self):
     """Verify setting the UL corner of the main app window in config"""
     cfg = config.Configure(pathfinder.config_path())
     str_coords = cfg.get_app_option_list("Coordinates")
     original_coords = (0, 0)
     if str_coords is not None:
         original_coords = [int(coord) for coord in str_coords]
     self.assertListEqual(original_coords, self.model.get_coords())
     new_coords_int = [3, 5]
     self.model.set_coords(new_coords_int)
     self.assertListEqual(new_coords_int, self.model.get_coords())
     new_coords_str = ["9", "-1"]
     self.model.set_coords(new_coords_str)
     self.assertListEqual([int(coord) for coord in new_coords_str], self.model.get_coords())
     self.model.set_coords(original_coords)
예제 #11
0
def get_config():
    """Returns a Configure instance pointing to the application's
    default configuration file."""
    return config.Configure(pathfinder.config_path())
예제 #12
0
 def test_config_path(self):
     """Verify correct path to configuration file"""
     config_path = os.path.normcase(os.path.expanduser("~/nditoolbox.cfg"))
     self.assertEqual(config_path, pathfinder.config_path())
예제 #13
0
 def test_get_preview_state(self):
     """Verify returning the current setting for displaying plot thumbnails"""
     cfg = config.Configure(pathfinder.config_path())
     preview_state = cfg.get_app_option_boolean("Enable Preview")
     self.assertEqual(preview_state, self.model.get_preview_state())
예제 #14
0
def get_config():
    """Returns a Configure instance pointing to the application's
    default configuration file."""
    return config.Configure(pathfinder.config_path())
예제 #15
0
 def test_config_path(self):
     """Verify correct path to configuration file"""
     config_path = os.path.normcase(os.path.expanduser("~/nditoolbox.cfg"))
     self.assertEqual(config_path, pathfinder.config_path())