def test_file(self): """Test that metadata file can be set""" argv = ['neurotic', self.temp_file] args = neurotic.parse_args(argv) win = neurotic.win_from_args(args) self.assertEqual(win.metadata_selector.file, self.temp_file, 'file was not changed correctly')
def test_no_lazy(self): """Test that --no-lazy disables lazy loading""" argv = ['neurotic', '--no-lazy'] args = neurotic.parse_args(argv) app = mkQApp() win = neurotic.win_from_args(args) self.assertFalse(win.lazy, 'lazy loading enabled with --no-lazy')
def test_cli_defaults(self): """Test CLI default values match factory defaults""" argv = ['neurotic'] args = neurotic.parse_args(argv) app = mkQApp() win = neurotic.win_from_args(args) # should match factory defaults because setUp() explicitly reset the # defaults to the factory defaults factory_defaults = neurotic._global_config_factory_defaults['defaults'] self.assertEqual(win.do_toggle_debug_logging.isChecked(), factory_defaults['debug'], 'debug setting has unexpected default') self.assertEqual(win.lazy, factory_defaults['lazy'], 'lazy setting has unexpected default') self.assertEqual(win.support_increased_line_width, factory_defaults['thick_traces'], 'thick traces setting has unexpected default') self.assertEqual(win.show_datetime, factory_defaults['show_datetime'], 'show_datetime has unexpected default') self.assertEqual(win.ui_scale, factory_defaults['ui_scale'], 'ui_scale has unexpected default') self.assertEqual(win.theme, factory_defaults['theme'], 'theme has unexpected default') self.assertEqual(win.metadata_selector.file, self.example_file, 'file has unexpected default') self.assertEqual(win.metadata_selector._selection, self.example_dataset, 'dataset has unexpected default')
def test_debug(self): """Test that --debug enables logging of debug messages""" argv = ['neurotic', '--debug'] args = neurotic.parse_args(argv) app = mkQApp() win = neurotic.win_from_args(args) self.assertTrue(win.do_toggle_debug_logging.isChecked(), 'debug logging disabled with --debug')
def test_dataset(self): """Test that dataset can be set""" argv = ['neurotic', self.temp_file, 'zzz_alphabetically_last'] args = neurotic.parse_args(argv) win = neurotic.win_from_args(args) self.assertEqual(win.metadata_selector._selection, 'zzz_alphabetically_last', 'dataset was not changed correctly')
def test_show_datetime(self): """Test that --show-datetime enables display of real-world datetime""" argv = ['neurotic', '--show-datetime'] args = neurotic.parse_args(argv) app = mkQApp() win = neurotic.win_from_args(args) self.assertTrue(win.show_datetime, 'datetime not displayed with --show-datetime')
def test_thick_traces(self): """Test that --thick-traces enables support for thick traces""" argv = ['neurotic', '--thick-traces'] args = neurotic.parse_args(argv) app = mkQApp() win = neurotic.win_from_args(args) self.assertTrue(win.support_increased_line_width, 'thick traces disabled with --thick-traces')
def test_dataset(self): """Test that dataset can be set""" argv = ['neurotic', self.temp_file, self.duplicate_dataset] args = neurotic.parse_args(argv) win = neurotic.win_from_args(args) self.assertEqual(win.metadata_selector._selection, self.duplicate_dataset, 'dataset was not changed correctly')
def test_no_show_datetime(self): """Test that --no-show-datetime hides the real-world datetime""" argv = ['neurotic', '--no-show-datetime'] args = neurotic.parse_args(argv) app = mkQApp() win = neurotic.win_from_args(args) self.assertFalse(win.show_datetime, 'datetime displayed with --no-show-datetime')
def test_theme(self): """Test that --theme changes the theme""" app = mkQApp() for theme in neurotic.available_themes: argv = ['neurotic', '--theme', theme] args = neurotic.parse_args(argv) win = neurotic.win_from_args(args) self.assertEqual(win.theme, theme, 'unexpected theme')
def test_ui_scale(self): """Test that --ui-scale changes the ui_scale""" app = mkQApp() for size in neurotic.available_ui_scales: argv = ['neurotic', '--ui-scale', size] args = neurotic.parse_args(argv) win = neurotic.win_from_args(args) self.assertEqual(win.ui_scale, size, 'unexpected scale')
def test_use_factory_defaults(self): """Test that --use-factory-defaults resets all defaults""" for k in neurotic.global_config['defaults']: neurotic.global_config['defaults'][k] = 'bad value' argv = ['neurotic', '--use-factory-defaults'] args = neurotic.parse_args(argv) for k, v in neurotic._global_config_factory_defaults['defaults'].items( ): self.assertEqual(getattr(args, k), v, f'args.{k} was not reset to factory default')
def test_example_file_and_first_dataset_overrides(self): """Test that 'example' and 'first' open first dataset in example file""" neurotic.global_config['defaults']['file'] = 'some other file' neurotic.global_config['defaults']['dataset'] = 'some other dataset' argv = ['neurotic', 'example', 'first'] args = neurotic.parse_args(argv) win = neurotic.win_from_args(args) self.assertEqual(win.metadata_selector.file, self.example_file, 'file was not changed correctly') self.assertEqual(win.metadata_selector._selection, self.example_dataset, 'dataset was not changed correctly')
def test_theme(self): """Test that --theme changes the theme""" app = mkQApp() argv = ['neurotic', '--theme', 'light'] args = neurotic.parse_args(argv) win = neurotic.win_from_args(args) self.assertEqual(win.theme, 'light', 'unexpected theme') argv = ['neurotic', '--theme', 'dark'] args = neurotic.parse_args(argv) win = neurotic.win_from_args(args) self.assertEqual(win.theme, 'dark', 'unexpected theme') argv = ['neurotic', '--theme', 'original'] args = neurotic.parse_args(argv) win = neurotic.win_from_args(args) self.assertEqual(win.theme, 'original', 'unexpected theme') argv = ['neurotic', '--theme', 'printer-friendly'] args = neurotic.parse_args(argv) win = neurotic.win_from_args(args) self.assertEqual(win.theme, 'printer-friendly', 'unexpected theme')
def test_cli_defaults(self): """Test CLI default values""" argv = ['neurotic'] args = neurotic.parse_args(argv) app = mkQApp() win = neurotic.win_from_args(args) self.assertTrue(win.lazy, 'lazy loading disabled without --no-lazy') self.assertFalse(win.support_increased_line_width, 'thick traces enabled without --thick-traces') self.assertFalse(win.show_datetime, 'datetime enabled without --show-datetime') self.assertEqual(win.theme, 'light', 'theme changed without --theme') self.assertEqual(win.metadata_selector.file, self.default_file, 'file was not set to default') self.assertEqual(win.metadata_selector._selection, self.default_dataset, 'dataset was not set to default dataset')