def test_create_metadata_should_succeed(self, content_type, golden_json):
        associated_file1 = metadata_info.AssociatedFileMd(
            file_path=self._LABEL_FILE_EN, locale="en")
        associated_file2 = metadata_info.AssociatedFileMd(
            file_path=self._LABEL_FILE_CN, locale="cn")

        tensor_md = metadata_info.TensorMd(
            name=self._TENSOR_NAME,
            description=self._TENSOR_DESCRIPTION,
            min_values=[self._TENSOR_MIN],
            max_values=[self._TENSOR_MAX],
            content_type=content_type,
            associated_files=[associated_file1, associated_file2])
        tensor_metadata = tensor_md.create_metadata()

        metadata_json = _metadata.convert_to_json(
            _create_dummy_model_metadata(tensor_metadata))
        expected_json = test_utils.load_file(golden_json, "r")
        self.assertEqual(metadata_json, expected_json)
    def test_create_metadata_should_succeed(self):
        file_md = metadata_info.AssociatedFileMd(
            file_path="label.txt",
            description="The label file.",
            file_type=_metadata_fb.AssociatedFileType.TENSOR_AXIS_LABELS,
            locale="en")
        file_metadata = file_md.create_metadata()

        # Create the Flatbuffers object and convert it to the json format.
        model_metadata = _metadata_fb.ModelMetadataT()
        model_metadata.associatedFiles = [file_metadata]
        builder = flatbuffers.Builder(0)
        builder.Finish(model_metadata.Pack(builder),
                       _metadata.MetadataPopulator.METADATA_FILE_IDENTIFIER)
        metadata_json = _metadata.convert_to_json(bytes(builder.Output()))

        expected_json = test_utils.load_file(self._EXPECTED_META_JSON, "r")
        self.assertEqual(metadata_json, expected_json)