def test_read_and_write_seed(self): """ Reads all SEED records from the Bavarian network and writes them again. This should not change them. There are some differences which will be edited before comparison: - The written SEED file will always have the version 2.4. BW uses version 2.3. The different formating of numbers in the stations blockettes will not be changed but 'evened'. Both are valid ways to do it - see SEED-Manual chapter 3 for more informations. """ # Loop over all files. for file in (self.BW_SEED_files[-1], ): f = open(file, 'rb') # Original SEED file. original_seed = f.read() f.seek(0) # Parse and write the data. parser = Parser(f) f.close() new_seed = parser.get_seed() # compare both SEED strings compare_seed(original_seed, new_seed) del parser parser1 = Parser(original_seed) parser2 = Parser(new_seed) self.assertEqual(parser1.get_seed(), parser2.get_seed()) del parser1, parser2
def test_read_and_write_seed(self): """ Reads all SEED records from the Bavarian network and writes them again. This should not change them. There are some differences which will be edited before comparison: - The written SEED file will always have the version 2.4. BW uses version 2.3. The different formating of numbers in the stations blockettes will not be changed but 'evened'. Both are valid ways to do it - see SEED-Manual chapter 3 for more informations. """ # Loop over all files. for file in (self.BW_SEED_files[-1],): f = open(file, 'rb') # Original SEED file. original_seed = f.read() f.seek(0) # Parse and write the data. parser = Parser(f) f.close() new_seed = parser.get_seed() # compare both SEED strings compare_seed(original_seed, new_seed) del parser parser1 = Parser(original_seed) parser2 = Parser(new_seed) self.assertEqual(parser1.get_seed(), parser2.get_seed()) del parser1, parser2
def test_xseed2dataless(self): with NamedTemporaryFile() as tf: with CatchOutput() as out: obspy_xseed2dataless(['--output', tf.name, self.xseed_file]) expected = '''Found 1 files. Parsing file %s ''' % (self.xseed_file, ) self.assertEqual(expected, out.stdout) with open(self.dataless_file, 'rb') as fh: expected = fh.read() with open(tf.name, 'rb') as fh: actual = fh.read() try: compare_seed(expected, actual) except Exception: self.fail('compare_seed raised Exception unexpectedly!') parser1 = Parser(expected) parser2 = Parser(actual) self.assertEqual(parser1.get_seed(), parser2.get_seed())
def test_xseed2dataless(self): with NamedTemporaryFile() as tf: with CatchOutput() as out: obspy_xseed2dataless(['--output', tf.name, self.xseed_file]) expected = '''Found 1 files. Parsing file %s ''' % (self.xseed_file,) self.assertEqual(expected, out.stdout) with open(self.dataless_file, 'rb') as fh: expected = fh.read() with open(tf.name, 'rb') as fh: actual = fh.read() try: compare_seed(expected, actual) except Exception: self.fail('compare_seed raised Exception unexpectedly!') parser1 = Parser(expected) parser2 = Parser(actual) self.assertEqual(parser1.get_seed(), parser2.get_seed())