code: def testArtifact(self):
      instance = _MyArtifact()
  
      # Test property getters.
      self.assertEqual("", instance.uri)
      self.assertEqual(0, instance.id)
      self.assertEqual(0, instance.type_id)
      self.assertEqual("MyTypeName", instance.type_name)
      self.assertEqual("", instance.state)
      self.assertFalse(instance.is_external)
  
      # Default property does not have span or split_names.
      with self.assertRaisesRegex(
          AttributeError, "has no property 'span'"
      ):
          instance.span  # pylint: disable=pointless-statement
      with self.assertRaisesRegex(
          AttributeError, "has no property 'split_names'"
      ):
          instance.split_names  # pylint: disable=pointless-statement
  
      # Test property setters.
      instance.name = "test_artifact"
      self.assertEqual("test_artifact", instance.name)
  
      instance.uri = "/tmp/uri2"
      self.assertEqual("/tmp/uri2", instance.uri)
  
      instance.id = 1
      self.assertEqual(1, instance.id)
  
      instance.type_id = 2
      self.assertEqual(2, instance.type_id)
  
      instance.state = artifact.ArtifactState.DELETED
      self.assertEqual(artifact.ArtifactState.DELETED, instance.state)
  
      instance.is_external = True
      self.assertTrue(instance.is_external)
  
      # Default artifact does not have span.
      with self.assertRaisesRegex(
          AttributeError, "unknown property 'span'"
      ):
          instance.span = 20190101
      # Default artifact does not have span.
      with self.assertRaisesRegex(
          AttributeError, "unknown property 'split_names'"
      ):
          instance.split_names = ""
  
      self.assertFalse(instance.has_custom_property("int_key"))
      instance.set_int_custom_property("int_key", 20)
      self.assertEqual(
          20,
          instance.mlmd_artifact.custom_properties["int_key"].int_value,
      )
      self.assertTrue(instance.has_custom_property("int_key"))
  
      instance.set_string_custom_property("string_key", "string_value")
      self.assertEqual(
          "string_value",
          instance.mlmd_artifact.custom_properties[
              "string_key"
          ].string_value,
      )
  
      instance.set_float_custom_property("float_key", 0.5)
      self.assertEqual(
          0.5,
          instance.mlmd_artifact.custom_properties[
              "float_key"
          ].double_value,
      )
  
      instance.set_bool_custom_property("bool_key", True)
      self.assertTrue(
          instance.mlmd_artifact.custom_properties[
              "bool_key"
          ].bool_value
      )
      self.assertFalse(instance.get_bool_custom_property("fake_key"))
  
      self.assertEqual(
          textwrap.dedent(
              """\
          Artifact(artifact: id: 1
          type_id: 2
          uri: "/tmp/uri2"
          custom_properties {
            key: "bool_key"
            value {
              bool_value: true
            }
          }
          custom_properties {
            key: "float_key"
            value {
              double_value: 0.5
            }
          }
          custom_properties {
            key: "int_key"
            value {
              int_value: 20
            }
          }
          custom_properties {
            key: "is_external"
            value {
              int_value: 1
            }
          }
          custom_properties {
            key: "name"
            value {
              string_value: "test_artifact"
            }
          }
          custom_properties {
            key: "string_key"
            value {
              string_value: "string_value"
            }
          }
          state: DELETED
          name: "test_artifact"
          , artifact_type: name: "MyTypeName"
          properties {
            key: "bool1"
            value: BOOLEAN
          }
          properties {
            key: "float1"
            value: DOUBLE
          }
          properties {
            key: "float2"
            value: DOUBLE
          }
          properties {
            key: "int1"
            value: INT
          }
          properties {
            key: "int2"
            value: INT
          }
          properties {
            key: "proto1"
            value: PROTO
          }
          properties {
            key: "proto2"
            value: PROTO
          }
          properties {
            key: "string1"
            value: STRING
          }
          properties {
            key: "string2"
            value: STRING
          }
          )"""
          ),
          str(instance),
      )
  
      # Test json serialization.
      json_dict = json_utils.dumps(instance)
      other_instance = json_utils.loads(json_dict)
      self.assertEqual(
          instance.mlmd_artifact, other_instance.mlmd_artifact
      )
      self.assertEqual(
          instance.artifact_type, other_instance.artifact_type
      )
  
imports: import json
  import textwrap
  from unittest import mock
  from absl import logging
  import tensorflow
  from tfx.types import artifact
  from tfx.types import system_artifacts
  from tfx.types import value_artifact
  from tfx.utils import json_utils
  from google.protobuf import struct_pb2
  from google.protobuf import json_format
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 1 for calling the ArtifactTest obj's underlying member method code with example usage: obj.testArtifact() without return types