def test_items(self): filename = os.path.join(self.input_path, SetupParser.ini_filename) SetupParser.init(selected_block='TEST', setup_file=filename, is_testing=True) self.assertEqual(len(SetupParser.items()), 24) self.assertEqual(len(SetupParser.items(block='HPC')), 20)
def test_verify_override_block(self): """ 1) set the SetupParser once to get the expected value, unset it, then 2) load a different selected block & then override it to the first. Should get same answer both routes. """ SetupParser.init(selected_block='LOCAL', is_testing=True) expected_params = dict(SetupParser.items(SetupParser.selected_block)) SetupParser._uninit() SetupParser.init(selected_block='HPC', is_testing=True) SetupParser.override_block('LOCAL') override_params = dict(SetupParser.items(SetupParser.selected_block)) self.assertEqual(override_params, expected_params)
def test_commandline(self): commandline = self.cb.get_commandline('input/file.txt', dict(SetupParser.items())) self.assertEqual('input/file.txt', commandline.Commandline) another_command = CommandlineGenerator('input/file.txt', {'--config': 'config.json'}, []) self.assertEqual('input/file.txt --config config.json', another_command.Commandline)
def test_stage_exe(self): local_setup = dict(SetupParser.items()) file1 = os.path.join(self.dummy_exe_folder, 'dummy_exe.txt') md5 = get_md5(file1) self.cb.stage_executable(file1, SetupParser.get('bin_staging_root')) staged_dir = os.path.join(SetupParser.get('bin_staging_root'), md5) staged_path = os.path.join(staged_dir, 'dummy_exe.txt') self.assertTrue(os.path.exists(staged_path)) file2 = os.path.join(self.another_dummy_exe_folder, 'dummy_exe.txt') os.chmod( file2, stat.S_IREAD ) # This is not writeable, but should not error because it isn't copied another_md5 = get_md5(file2) self.cb.stage_executable(file2, SetupParser.get('bin_staging_root')) self.assertEqual(md5, another_md5) self.cb.stage_executable('\\\\remote\\path\\to\\file.exe', local_setup) os.remove(staged_path) os.rmdir(staged_dir)