def main(): """ iodp_samples_magic.py OPTIONS: -f FILE, input csv file -Fsa FILE, output er_samples.txt file for updating, default is to overwrite er_samples.txt """ if "-h" in sys.argv: print main.__doc__ sys.exit() dataframe = extractor.command_line_dataframe([['WD', False, '.'], ['ID', False, '.'], ['f', True, ''], ['Fsa', False, None]]) args = sys.argv checked_args = extractor.extract_and_check_args(args, dataframe) samp_file, output_samp_file, output_dir_path, input_dir_path = extractor.get_vars(['f', 'Fsa', 'WD', 'ID'], checked_args) ipmag.iodp_samples_magic(samp_file, output_samp_file, output_dir_path, input_dir_path)
def test_content_with_right_format(self): reference_file = os.path.join(WD, 'data_files', 'testing', 'odp_magic', 'odp_magic_er_samples.txt') infile = os.path.join(self.input_dir, 'samples_318_U1359_B.csv') program_ran, outfile = ipmag.iodp_samples_magic(infile) self.assertEqual( open(reference_file).readlines(), open(outfile).readlines())
def test_with_right_format(self): reference_file = os.path.join(WD, 'testing', 'odp_magic', 'odp_magic_er_samples.txt') infile = os.path.join(self.input_dir, 'samples_318_U1359_B.csv') program_ran, outfile = ipmag.iodp_samples_magic(infile) self.assertTrue(program_ran) expected_file = os.path.join('.', 'er_samples.txt') self.assertEqual(outfile, expected_file) self.assertTrue(os.path.isfile(outfile))
def test_content_with_right_format(self): reference_file = os.path.join(WD, 'data_files', 'testing', 'odp_magic', 'odp_magic_er_samples.txt') infile = os.path.join(self.input_dir, 'samples_318_U1359_B.csv') program_ran, outfile = ipmag.iodp_samples_magic(infile) with open(reference_file) as ref_file: ref_lines = ref_file.readlines() with open(outfile) as out_file: out_lines = out_file.readlines() self.assertTrue(program_ran) self.assertEqual(ref_lines, out_lines)
def test_with_wrong_format(self): infile = os.path.join(self.input_dir, 'GCR_U1359_B_coresummary.csv') program_ran, error_message = ipmag.iodp_samples_magic(infile) self.assertFalse(program_ran) expected_error = 'Could not extract the necessary data from your input file.\nPlease make sure you are providing a correctly formated IODP samples csv file.' self.assertEqual(error_message, expected_error)
def test_content_with_right_format(self): reference_file = os.path.join(WD, 'pmagpy_data_files', 'testing', 'odp_magic', 'odp_magic_er_samples.txt') infile = os.path.join(self.input_dir, 'samples_318_U1359_B.csv') program_ran, outfile = ipmag.iodp_samples_magic(infile) self.assertEqual(open(reference_file).readlines(), open(outfile).readlines())