Esempio n. 1
0
 def test_from_line_trim_whitespace_at_the_end_of_value(self):
     for line in ["#key value ", "#key value  ", "#key value\t"]:
         record, error = MafHeaderRecord.from_line(line=line)
         self.assertIsNotNone(record)
         self.assertIsNone(error)
         self.assertFalse(isinstance(record, MafHeaderVersionRecord))
         self.assertTrue(isinstance(record, MafHeaderRecord))
         self.assertEqual(record.key, "key")
         self.assertEqual(record.value, "value")
Esempio n. 2
0
 def __test_from_line_with_error(self, lines, tpe):
     """
     A helper method for testing when MafHeaderRecord.from_line returns an error.
     """
     for line in lines:
         record, error = MafHeaderRecord.from_line(line=line)
         self.assertIsNone(record)
         self.assertIsNotNone(error)
         self.assertEqual(error.tpe, tpe)
Esempio n. 3
0
    def test_from_line_version_record(self):
        """
        Tests that a MafHeaderVersionRecord is returned from MafHeaderRecord.from_line only when it encounters
        MafHeader.VersionKey.
        """
        for line in [
                "#%s %s" % (MafHeader.VersionKey, version)
                for version in MafHeader.SupportedVersions
        ]:
            record, error = MafHeaderRecord.from_line(line=line)
            self.assertIsNotNone(record)
            self.assertIsNone(error)
            self.assertTrue(isinstance(record, MafHeaderVersionRecord))
            self.assertTrue(isinstance(record, MafHeaderRecord))

        for line in ["#garbage value", "#%sz value"]:
            record, error = MafHeaderRecord.from_line(line=line)
            self.assertIsNotNone(record)
            self.assertIsNone(error)
            self.assertFalse(isinstance(record, MafHeaderVersionRecord))
            self.assertTrue(isinstance(record, MafHeaderRecord))