@@ -198,6 +198,9 @@ def bigframes_import_mock():
198
198
bigframes_module .bigquery = bbq_module
199
199
sys .modules ["bigframes" ] = bigframes_module
200
200
201
+ bigframes_module .BigQueryOptions = mock .MagicMock ()
202
+ bigframes_module .connect = mock .MagicMock ()
203
+
201
204
yield bigframes_module , bpd_module , bbq_module
202
205
203
206
del sys .modules ["bigframes" ]
@@ -461,8 +464,6 @@ def test_create_dataset_from_gemini_request_jsonl(
461
464
bpd_module .read_pandas = mock .MagicMock ()
462
465
bbq_module .parse_json = lambda x : x
463
466
464
- bf_module .BigQueryOptions = mock .MagicMock ()
465
- bf_module .connect = mock .MagicMock ()
466
467
session_mock = mock .MagicMock ()
467
468
bf_module .connect .return_value .__enter__ .return_value = session_mock
468
469
@@ -744,6 +745,53 @@ def test_assemble_request_column_name(self, assemble_data_mock):
744
745
)
745
746
assert result_table_id == _TEST_ASSEMBLE_DATA_BIGQUERY_DESTINATION [5 :]
746
747
748
+ @pytest .mark .usefixtures ("get_dataset_mock" )
749
+ def test_create_dataset_from_pandas_multiregion_target_table_allowed (
750
+ self , create_dataset_mock , bigframes_import_mock , bq_client_mock
751
+ ):
752
+ bq_client_mock .return_value .get_dataset .return_value .location = "us"
753
+
754
+ _ , bpd_module , _ = bigframes_import_mock
755
+
756
+ bpd_module .read_pandas = lambda x : mock .Mock ()
757
+ aiplatform .init (project = _TEST_PROJECT )
758
+ dataframe = pandas .DataFrame (
759
+ {
760
+ "question" : ["question" ],
761
+ "answer" : ["answer" ],
762
+ }
763
+ )
764
+ ummd .MultimodalDataset .from_pandas (
765
+ dataframe = dataframe ,
766
+ target_table_id = _TEST_TARGET_BQ_TABLE ,
767
+ display_name = _TEST_DISPLAY_NAME ,
768
+ location = "us-central1" ,
769
+ )
770
+ create_dataset_mock .assert_called_once ()
771
+
772
+ def test_create_dataset_from_pandas_multiregion_target_table_location_mismatch_throws_error (
773
+ self , bigframes_import_mock , bq_client_mock
774
+ ):
775
+ bq_client_mock .return_value .get_dataset .return_value .location = "eu"
776
+
777
+ _ , bpd_module , _ = bigframes_import_mock
778
+
779
+ bpd_module .read_pandas = lambda x : mock .Mock ()
780
+ aiplatform .init (project = _TEST_PROJECT )
781
+ dataframe = pandas .DataFrame (
782
+ {
783
+ "question" : ["question" ],
784
+ "answer" : ["answer" ],
785
+ }
786
+ )
787
+ with pytest .raises (ValueError ):
788
+ ummd .MultimodalDataset .from_pandas (
789
+ dataframe = dataframe ,
790
+ target_table_id = _TEST_TARGET_BQ_TABLE ,
791
+ display_name = _TEST_DISPLAY_NAME ,
792
+ location = "us-central1" ,
793
+ )
794
+
747
795
748
796
class TestGeminiExample :
749
797
"""Tests for the GeminiExample class."""
0 commit comments