def test_use_different_scheme(self): lines = [ "%s%s %s" % ( MafHeader.HeaderLineStartSymbol, MafHeader.VersionKey, GdcV1_0_0_ProtectedScheme.version(), ), "%s%s %s" % ( MafHeader.HeaderLineStartSymbol, MafHeader.AnnotationSpecKey, GdcV1_0_0_ProtectedScheme.annotation_spec(), ), "\t".join(GdcV1_0_0_BasicScheme().column_names()), ] reader = MafReader(lines=lines, scheme=None) self.assertIsNone(next(reader, None)) self.assertEqual(len(reader.validation_errors), 1) self.assertListEqual( [e.tpe for e in reader.validation_errors], [MafValidationErrorType.SCHEME_MISMATCHING_NUMBER_OF_COLUMN_NAMES], ) self.assertEqual(reader.header().scheme().version(), GdcV1_0_0_BasicScheme.version()) self.assertEqual(reader.scheme().version(), GdcV1_0_0_ProtectedScheme().version()) self.assertEqual( reader.scheme().annotation_spec(), GdcV1_0_0_ProtectedScheme.annotation_spec(), ) self.assertEqual( reader.header().scheme().annotation_spec(), GdcV1_0_0_ProtectedScheme.annotation_spec(), )
def test_use_scheme_from_header_basic(self): version = "%s%s %s" % ( MafHeader.HeaderLineStartSymbol, MafHeader.VersionKey, GdcV1_0_0_BasicScheme.version(), ) lines = [version, "\t".join(GdcV1_0_0_BasicScheme().column_names())] reader = MafReader(lines=lines, scheme=None) self.assertIsNone(next(reader, None)) self.assertEqual(len(reader.validation_errors), 0) self.assertEqual(reader.header().scheme().version(), GdcV1_0_0_BasicScheme().version())
def test_use_default_scheme(self): lines = [ TestMafReader.AnnotationSpec, "\t".join(GdcV1_0_0_BasicScheme().column_names()), ] reader = MafReader(lines=lines, scheme=None) self.assertIsNone(next(reader, None)) self.assertEqual(len(reader.validation_errors), 2) self.assertListEqual( [e.tpe for e in reader.validation_errors], [ MafValidationErrorType.HEADER_MISSING_VERSION, MafValidationErrorType.HEADER_UNSUPPORTED_ANNOTATION_SPEC, ], ) self.assertIsNone(reader.header().scheme()) self.assertEqual( reader.scheme().version(), NoRestrictionsScheme(column_names=list()).version(), )