@@ -206,6 +206,27 @@ def create_context_mock():
206
206
yield create_context_mock
207
207
208
208
209
+ @pytest .fixture
210
+ def list_artifacts_mock ():
211
+ with patch .object (MetadataServiceClient , "list_artifacts" ) as list_artifacts_mock :
212
+ list_artifacts_mock .return_value = []
213
+ yield list_artifacts_mock
214
+
215
+
216
+ @pytest .fixture
217
+ def list_executions_mock ():
218
+ with patch .object (MetadataServiceClient , "list_executions" ) as list_executions_mock :
219
+ list_executions_mock .return_value = []
220
+ yield list_executions_mock
221
+
222
+
223
+ @pytest .fixture
224
+ def list_contexts_mock ():
225
+ with patch .object (MetadataServiceClient , "list_contexts" ) as list_contexts_mock :
226
+ list_contexts_mock .return_value = []
227
+ yield list_contexts_mock
228
+
229
+
209
230
@pytest .mark .usefixtures ("google_auth_mock" )
210
231
class TestMetadataBaseArtifactSchema :
211
232
def setup_method (self ):
@@ -369,6 +390,20 @@ class TestArtifact(base_artifact.BaseArtifactSchema):
369
390
"sdk_command/aiplatform.metadata.schema.base_artifact.BaseArtifactSchema._init_with_resource_name"
370
391
]
371
392
393
+ def test_list_artifacts (self , list_artifacts_mock ):
394
+ aiplatform .init (project = _TEST_PROJECT , location = _TEST_LOCATION )
395
+
396
+ class TestArtifact (base_artifact .BaseArtifactSchema ):
397
+ schema_title = _TEST_SCHEMA_TITLE
398
+
399
+ TestArtifact .list ()
400
+ list_artifacts_mock .assert_called_once_with (
401
+ request = {
402
+ "parent" : f"{ _TEST_PARENT } /metadataStores/default" ,
403
+ "filter" : f'schema_title="{ _TEST_SCHEMA_TITLE } "' ,
404
+ }
405
+ )
406
+
372
407
373
408
@pytest .mark .usefixtures ("google_auth_mock" )
374
409
class TestMetadataBaseExecutionSchema :
@@ -563,6 +598,20 @@ class TestExecution(base_execution.BaseExecutionSchema):
563
598
"sdk_command/aiplatform.metadata.schema.base_execution.BaseExecutionSchema._init_with_resource_name"
564
599
]
565
600
601
+ def test_list_executions (self , list_executions_mock ):
602
+ aiplatform .init (project = _TEST_PROJECT , location = _TEST_LOCATION )
603
+
604
+ class TestExecution (base_execution .BaseExecutionSchema ):
605
+ schema_title = _TEST_SCHEMA_TITLE
606
+
607
+ TestExecution .list ()
608
+ list_executions_mock .assert_called_once_with (
609
+ request = {
610
+ "parent" : f"{ _TEST_PARENT } /metadataStores/default" ,
611
+ "filter" : f'schema_title="{ _TEST_SCHEMA_TITLE } "' ,
612
+ }
613
+ )
614
+
566
615
567
616
@pytest .mark .usefixtures ("google_auth_mock" )
568
617
class TestMetadataBaseContextSchema :
@@ -730,6 +779,20 @@ class TestContext(base_context.BaseContextSchema):
730
779
"sdk_command/aiplatform.metadata.schema.base_context.BaseContextSchema._init_with_resource_name"
731
780
]
732
781
782
+ def test_list_contexts (self , list_contexts_mock ):
783
+ aiplatform .init (project = _TEST_PROJECT , location = _TEST_LOCATION )
784
+
785
+ class TestContext (base_context .BaseContextSchema ):
786
+ schema_title = _TEST_SCHEMA_TITLE
787
+
788
+ TestContext .list ()
789
+ list_contexts_mock .assert_called_once_with (
790
+ request = {
791
+ "parent" : f"{ _TEST_PARENT } /metadataStores/default" ,
792
+ "filter" : f'schema_title="{ _TEST_SCHEMA_TITLE } "' ,
793
+ }
794
+ )
795
+
733
796
734
797
@pytest .mark .usefixtures ("google_auth_mock" )
735
798
class TestMetadataGoogleArtifactSchema :
0 commit comments