1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15+ from typing import Callable
1516from unittest import mock
1617
1718import IPython .display
1819import pandas as pd
20+ import pytest
1921
2022import bigframes
2123import bigframes .pandas as bpd
2224
2325
2426def test_blob_create_from_uri_str (
25- bq_connection : str , session : bigframes .Session , images_uris
27+ bq_connection : str ,
28+ session : bigframes .Session ,
29+ images_uris ,
30+ normalize_connection_id : Callable [[str ], str ],
2631):
2732 uri_series = bpd .Series (images_uris , session = session )
2833 blob_series = uri_series .str .to_blob (connection = bq_connection )
2934
3035 pd_blob_df = blob_series .struct .explode ().to_pandas ()
36+ pd_blob_df ["authorizer" ] = pd_blob_df ["authorizer" ].apply (normalize_connection_id )
3137 expected_pd_df = pd .DataFrame (
3238 {
3339 "uri" : images_uris ,
3440 "version" : [None , None ],
35- "authorizer" : [bq_connection .casefold (), bq_connection .casefold ()],
41+ "authorizer" : [
42+ normalize_connection_id (bq_connection ),
43+ normalize_connection_id (bq_connection ),
44+ ],
3645 "details" : [None , None ],
3746 }
3847 )
@@ -43,7 +52,11 @@ def test_blob_create_from_uri_str(
4352
4453
4554def test_blob_create_from_glob_path (
46- bq_connection : str , session : bigframes .Session , images_gcs_path , images_uris
55+ bq_connection : str ,
56+ session : bigframes .Session ,
57+ images_gcs_path ,
58+ images_uris ,
59+ normalize_connection_id : Callable [[str ], str ],
4760):
4861 blob_df = session .from_glob_path (
4962 images_gcs_path , connection = bq_connection , name = "blob_col"
@@ -55,12 +68,16 @@ def test_blob_create_from_glob_path(
5568 .sort_values ("uri" )
5669 .reset_index (drop = True )
5770 )
71+ pd_blob_df ["authorizer" ] = pd_blob_df ["authorizer" ].apply (normalize_connection_id )
5872
5973 expected_df = pd .DataFrame (
6074 {
6175 "uri" : images_uris ,
6276 "version" : [None , None ],
63- "authorizer" : [bq_connection .casefold (), bq_connection .casefold ()],
77+ "authorizer" : [
78+ normalize_connection_id (bq_connection ),
79+ normalize_connection_id (bq_connection ),
80+ ],
6481 "details" : [None , None ],
6582 }
6683 )
@@ -71,7 +88,11 @@ def test_blob_create_from_glob_path(
7188
7289
7390def test_blob_create_read_gbq_object_table (
74- bq_connection : str , session : bigframes .Session , images_gcs_path , images_uris
91+ bq_connection : str ,
92+ session : bigframes .Session ,
93+ images_gcs_path ,
94+ images_uris ,
95+ normalize_connection_id : Callable [[str ], str ],
7596):
7697 obj_table = session ._create_object_table (images_gcs_path , bq_connection )
7798
@@ -83,11 +104,15 @@ def test_blob_create_read_gbq_object_table(
83104 .sort_values ("uri" )
84105 .reset_index (drop = True )
85106 )
107+ pd_blob_df ["authorizer" ] = pd_blob_df ["authorizer" ].apply (normalize_connection_id )
86108 expected_df = pd .DataFrame (
87109 {
88110 "uri" : images_uris ,
89111 "version" : [None , None ],
90- "authorizer" : [bq_connection .casefold (), bq_connection .casefold ()],
112+ "authorizer" : [
113+ normalize_connection_id (bq_connection ),
114+ normalize_connection_id (bq_connection ),
115+ ],
91116 "details" : [None , None ],
92117 }
93118 )
@@ -97,6 +122,7 @@ def test_blob_create_read_gbq_object_table(
97122 )
98123
99124
125+ @pytest .mark .skip (reason = "b/457416070" )
100126def test_display_images (monkeypatch , images_mm_df : bpd .DataFrame ):
101127 mock_display = mock .Mock ()
102128 monkeypatch .setattr (IPython .display , "display" , mock_display )
0 commit comments