MCPcopy Create free account
hub / github.com/apache/fory / verify_schema_mismatch

Function verify_schema_mismatch

benchmarks/python/benchmark.py:678–731  ·  view source on GitHub ↗
(datatype: str, decoded: Any, expected: Any)

Source from the content-addressed store, hash-verified

676
677
678def verify_schema_mismatch(datatype: str, decoded: Any, expected: Any) -> None:
679 if datatype == "struct":
680 if not isinstance(decoded, NumericStructV2) or decoded.f1 != expected.f1:
681 raise AssertionError("NumericStructV2 schema mismatch read failed")
682 return
683 if datatype == "sample":
684 if not isinstance(decoded, SampleV2) or decoded.int_value != expected.int_value:
685 raise AssertionError("SampleV2 schema mismatch read failed")
686 return
687 if datatype == "mediacontent":
688 if (
689 not isinstance(decoded, MediaContentV2)
690 or not isinstance(decoded.media, MediaV2)
691 or decoded.media.width != expected.media.width
692 or not decoded.images
693 or not isinstance(decoded.images[0], ImageV2)
694 or decoded.images[0].width != expected.images[0].width
695 ):
696 raise AssertionError("MediaContentV2 schema mismatch read failed")
697 return
698 if datatype == "structlist":
699 if (
700 not isinstance(decoded, NumericStructListV2)
701 or not decoded.struct_list
702 or not isinstance(decoded.struct_list[0], NumericStructV2)
703 or decoded.struct_list[0].f1 != expected.struct_list[0].f1
704 ):
705 raise AssertionError("NumericStructListV2 schema mismatch read failed")
706 return
707 if datatype == "samplelist":
708 if (
709 not isinstance(decoded, SampleListV2)
710 or not decoded.sample_list
711 or not isinstance(decoded.sample_list[0], SampleV2)
712 or decoded.sample_list[0].int_value != expected.sample_list[0].int_value
713 ):
714 raise AssertionError("SampleListV2 schema mismatch read failed")
715 return
716 if datatype == "mediacontentlist":
717 if (
718 not isinstance(decoded, MediaContentListV2)
719 or not decoded.media_content_list
720 or not isinstance(decoded.media_content_list[0], MediaContentV2)
721 or not isinstance(decoded.media_content_list[0].media, MediaV2)
722 or decoded.media_content_list[0].media.width
723 != expected.media_content_list[0].media.width
724 or not decoded.media_content_list[0].images
725 or not isinstance(decoded.media_content_list[0].images[0], ImageV2)
726 or decoded.media_content_list[0].images[0].width
727 != expected.media_content_list[0].images[0].width
728 ):
729 raise AssertionError("MediaContentListV2 schema mismatch read failed")
730 return
731 raise AssertionError(f"Unknown datatype for schema mismatch: {datatype}")
732
733
734def verify_fory_schema_mismatch(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected