class_docstr: Abstract class for integration testing concrete Metadata implementations.
  
  Subclasses should override metadata() to return an instance of Metadata that
  has not been entered.
class_docstr_tok: ["Abstract","class","for","integration","testing","concrete","Metadata","implementations",".","Subclasses","should","override","metadata","(",")","to","return","an","instance","of","Metadata","that","has","not","been","entered","."]
code: def testContext(self):
      with self.metadata() as m:
          contexts = m.register_pipeline_contexts_if_not_exists(
              self._pipeline_info
          )
          # Duplicated call should succeed.
          contexts = m.register_pipeline_contexts_if_not_exists(
              self._pipeline_info
          )
  
          pipeline_context_type = m.store.get_context_type(
              metadata._CONTEXT_TYPE_PIPELINE
          )  # pylint: disable=protected-access
          pipeline_context_type.ClearField("id")
          self.assertProtoEquals(
              """
            name: 'pipeline'
            properties {
              key: "pipeline_name"
              value: STRING
            }
            """,
              pipeline_context_type,
          )
          pipeline_run_context_type = m.store.get_context_type(
              metadata._CONTEXT_TYPE_PIPELINE_RUN
          )  # pylint: disable=protected-access
          pipeline_run_context_type.ClearField("id")
          self.assertProtoEquals(
              """
            name: 'run'
            properties {
              key: "pipeline_name"
              value: STRING
            }
            properties {
              key: "run_id"
              value: STRING
            }
            """,
              pipeline_run_context_type,
          )  # pylint: disable=protected-access
          self.assertEqual(len(contexts), 2)
          self.assertEqual(
              contexts[0],
              m.store.get_context_by_type_and_name(
                  metadata._CONTEXT_TYPE_PIPELINE,  # pylint: disable=protected-access
                  self._pipeline_info.pipeline_context_name,
              ),
          )
          self.assertEqual(
              contexts[1],
              m.store.get_context_by_type_and_name(
                  metadata._CONTEXT_TYPE_PIPELINE_RUN,  # pylint: disable=protected-access
                  self._pipeline_info.pipeline_run_context_name,
              ),
          )
  
imports: from typing import Mapping
  import tensorflow
  from tfx.orchestration import data_types
  from tfx.orchestration import metadata
  from tfx.types import artifact_utils
  from tfx.types import standard_artifacts
  from tfx.types.artifact import ArtifactState
  from ml_metadata.proto import metadata_store_pb2
label_desc: Use image node_id 18 for calling the MetadataTest obj's underlying member method code with example usage: obj.testContext() without return types