def test_load_default_config(self): """Test that the default config loads properly.""" expected_defaults = { 'casefiles_dir': os.getcwd() + '/casefiles', 'casefiles_entry_point': 'deputy.casefiles', } settings = config.load_config() self.assertEqual(expected_defaults, settings)
def test_iter_entrypoints_with_default_config(self): """Test basic setup.py entry_point config.""" from deputy import config from pkg_resources import iter_entry_points settings = config.load_config() entry_points = iter_entry_points(settings['casefiles_entry_point']) expected_entry_point_name = 'bang' depends_on = 'deputy_lib' try: __import__(depends_on) self.assertEqual(entry_points.next().name, expected_entry_point_name) except ImportError: warn('Skipping test, deputy_lib is not available.')
def run_casefile(casefile_name, casefile_argv): settings = config.load_config() # TODO: Revisit, super ugly. casefile_loaders = loaders.get_loaders(settings) casefiles = [ldr(casefile_name=casefile_name) for ldr in casefile_loaders] casefiles = chain(*casefiles) casefiles = list(casefiles) if len(casefiles) == 1: casefile = casefiles[0].load() casefile.run(casefile_argv) elif len(casefiles) > 1: raise CasefileConflictError() else: raise CasefileMissingError() pass
def print_available_casefiles(): available_header = 'Available casefiles:\n' available_casefile_format = '{name}\t{doc}' settings = config.load_config() casefile_loaders = loaders.get_loaders(settings) # TODO: Revisit, call to chain here is a bit clunky casefiles = [ldr() for ldr in casefile_loaders] casefiles = chain(*casefiles) print(available_header) for casefile in casefiles: name, doc = casefile.name(), casefile.help() print(available_casefile_format.format(name=name, doc=doc)) # Print newline. print()
def setUp(self): self.settings = config.load_config()