def test_session_get(self): with self.subTest(cmd="nemoa.get('base')"): test = isinstance(nemoa.get('base'), str) self.assertTrue(test) with self.subTest(cmd="nemoa.get('workspace')"): test = isinstance(nemoa.get('workspace'), str) self.assertTrue(test) with self.subTest(cmd="nemoa.get('default')"): test = isinstance(nemoa.get('default'), dict) self.assertTrue(test) with self.subTest(cmd="nemoa.get('default', 'filetype')"): test = isinstance(nemoa.get('default', 'filetype'), dict) self.assertTrue(test) with self.subTest(cmd="nemoa.get('default', 'filetype', 'dataset')"): filetype = nemoa.get('default', 'filetype', 'dataset') test = isinstance(filetype, str) self.assertTrue(test) with self.subTest(cmd="nemoa.get('default', 'filetype', 'network')"): filetype = nemoa.get('default', 'filetype', 'network') test = isinstance(filetype, str) self.assertTrue(test) with self.subTest(cmd="nemoa.get('default', 'filetype', 'system')"): filetype = nemoa.get('default', 'filetype', 'system') test = isinstance(filetype, str) self.assertTrue(test) with self.subTest(cmd="nemoa.get('default', 'filetype', 'model')"): filetype = nemoa.get('default', 'filetype', 'model') test = isinstance(filetype, str) self.assertTrue(test) with self.subTest(cmd="nemoa.get('default', 'filetype', 'script')"): filetype = nemoa.get('default', 'filetype', 'script') test = isinstance(filetype, str) self.assertTrue(test)
def print_scripts(workspace: str) -> None: """Print list of scripts to standard output.""" nemoa.set('mode', 'silent') if nemoa.open(workspace): ui.info('Scripts in workspace %s:\n' % (nemoa.get('workspace'))) for script in nemoa.list('scripts'): ui.info(' %s' % (script)) ui.info('')
def print_scripts(workspace): """Print list of scripts to standard output.""" import nemoa nemoa.set('mode', 'silent') if not nemoa.open(workspace): return False print(('Scripts in workspace %s:\n' % (nemoa.get('workspace')))) for script in nemoa.list('scripts'): print((' %s' % (script))) print() return True
def _get_path_default(self): """Get default filepath. Path to a potential file containing or referencing the resource. Returns: Basestring containing the potential path of the resource. """ module = self.__module__.split('.')[1] fileext = nemoa.get('default', 'filetype', module) path = nemoa.path(module + 's') or nemoa.common.ospath.getcwd() filename = '%s.%s' % (nemoa.common.ospath.get_clean_filename( self._get_fullname()), fileext) return nemoa.common.ospath.get_norm_path(path, filename)
def _update_keypress(self): """Check Keyboard.""" char = nemoa.get('shell', 'inkey') if not char: return True if char == 'e': pass elif char == 'h': nemoa.log('note', "Keyboard Shortcuts") nemoa.log('note', "'e' -- calculate evaluation function") nemoa.log('note', "'h' -- show this") nemoa.log('note', "'q' -- quit optimization") nemoa.log('note', "'t' -- estimate finishing time") elif char == 'q': nemoa.log('note', 'aborting optimization') self._buffer['continue'] = False elif char == 't': ftime = self._get_estimatetime() nemoa.log('note', 'estimated finishing time %s' % ftime) return True
def get(*args, **kwargs): """Wrapping function to nemoa.get().""" nemoa.log('note', nemoa.get(*args, **kwargs)) return None
def test_workspace_open(self): nemoa.open('testsuite') test = nemoa.get('workspace') == 'testsuite' self.assertTrue(test)
def run_unittest(): """Run unittest.""" import nemoa import unittest # initialize loader and test suite loader = unittest.TestLoader() suite = unittest.TestSuite() # open workspace 'testsuite' workspace = nemoa.get('workspace') nemoa.open('testsuite', base='site') # add tests to the test suite try: import nemoa.common.__test__ except ImportError: pass else: suite.addTests(loader.loadTestsFromModule(nemoa.common.__test__)) try: import nemoa.workspace.__test__ except ImportError: pass else: suite.addTests(loader.loadTestsFromModule( nemoa.workspace.__test__)) try: import nemoa.session.__test__ except ImportError: pass else: suite.addTests(loader.loadTestsFromModule(nemoa.session.__test__)) try: import nemoa.dataset.__test__ except ImportError: pass else: suite.addTests(loader.loadTestsFromModule(nemoa.dataset.__test__)) try: import nemoa.network.__test__ except ImportError: pass else: suite.addTests(loader.loadTestsFromModule(nemoa.network.__test__)) try: import nemoa.system.__test__ except ImportError: pass else: suite.addTests(loader.loadTestsFromModule(nemoa.system.__test__)) try: import nemoa.model.__test__ except ImportError: pass else: suite.addTests(loader.loadTestsFromModule(nemoa.model.__test__)) # initialize runner runner = unittest.TextTestRunner(verbosity=2) # run testsuite nemoa.log('testing nemoa ' + nemoa.__version__) result = runner.run(suite) # open previous workspace if nemoa.get('workspace') != workspace: nemoa.open(workspace) return result
def tearDown(self): # open previous workspace if nemoa.get('workspace') != self.workspace: nemoa.open(self.workspace) nemoa.set('mode', self.mode)
def setUp(self): self.mode = nemoa.get('mode') self.workspace = nemoa.get('workspace') nemoa.set('mode', 'silent') # open workspace 'testsuite' nemoa.open('testsuite', base='site')
def setUp(self): self.mode = nemoa.get('mode') self.workspace = nemoa.get('workspace') nemoa.set('mode', 'silent')