def test_blocketteLongerThanRecordLength(self): """ If a blockette is longer than the record length it should result in more than one record. """ parser = Parser(strict=True) # Set record length to 100. parser.record_length = 100 # Use a blockette 53 string. SEED_string = b'0530382A01002003+6.00770E+07+2.00000E-02002+0.00000E' \ b'+00+0.00000E+00+0.00000E+00+0.00000E+00+0.00000E+00+0.00000E+0' \ b'0+0.00000E+00+0.00000E+00005-3.70040E-02-3.70160E-02+0.00000E+' \ b'00+0.00000E+00-3.70040E-02+3.70160E-02+0.00000E+00+0.00000E+00' \ b'-2.51330E+02+0.00000E+00+0.00000E+00+0.00000E+00-1.31040E+02-4' \ b'.67290E+02+0.00000E+00+0.00000E+00-1.31040E+02+4.67290E+02+0.0' \ b'0000E+00+0.00000E+00' blkt_53 = Blockette053() blkt_53.parse_SEED(SEED_string) # This just tests an internal SEED method. records = parser._create_cut_and_flush_record([blkt_53], 'S') # This should result in five records. self.assertEqual(len(records), 5) # Each records should be 100 - 6 = 94 long. for record in records: self.assertEqual(len(record), 94) # Reassemble the String. new_string = b'' for record in records: new_string += record[2:] # Compare the new and the old string. self.assertEqual(new_string.strip(), SEED_string)
def test_blockette_longer_than_record_length(self): """ If a blockette is longer than the record length it should result in more than one record. """ parser = Parser(strict=True) # Set record length to 100. parser.record_length = 100 # Use a blockette 53 string. seed_string = b'0530382A01002003+6.00770E+07+2.00000E-02002+0.00000E' \ b'+00+0.00000E+00+0.00000E+00+0.00000E+00+0.00000E+00+0.00000E+0' \ b'0+0.00000E+00+0.00000E+00005-3.70040E-02-3.70160E-02+0.00000E+' \ b'00+0.00000E+00-3.70040E-02+3.70160E-02+0.00000E+00+0.00000E+00' \ b'-2.51330E+02+0.00000E+00+0.00000E+00+0.00000E+00-1.31040E+02-4' \ b'.67290E+02+0.00000E+00+0.00000E+00-1.31040E+02+4.67290E+02+0.0' \ b'0000E+00+0.00000E+00' blkt_53 = Blockette053() blkt_53.parse_seed(seed_string) # This just tests an internal SEED method. records = parser._create_cut_and_flush_record([blkt_53], 'S') # This should result in five records. self.assertEqual(len(records), 5) # Each records should be 100 - 6 = 94 long. for record in records: self.assertEqual(len(record), 94) # Reassemble the String. new_string = b'' for record in records: new_string += record[2:] # Compare the new and the old string. self.assertEqual(new_string.strip(), seed_string)