Skip to content

Commit 110eb7d

Browse files
fix(tests): Use spec for page mocks in test_get_ad_group_bid_modifiers.py
Updated `test_get_ad_group_bid_modifiers.py` to use the `spec` argument when creating `MagicMock` instances for `SearchGoogleAdsResponse` equivalents (named `mock_search_response_page` in the test). The spec is `['results']`. This change, in conjunction with using `MockGoogleAdsRow` for rows and `MockAdGroupBidModifierModel` for bid modifier objects, aims to ensure that the `results` attribute of the page mock returns the exact list of assigned `MockGoogleAdsRow` instances. This should preserve the custom types throughout the mock chain and resolve the persistent `AttributeError: type object 'MagicMock' has no attribute 'pb'`.
1 parent 2649f13 commit 110eb7d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/advanced_operations/tests/test_get_ad_group_bid_modifiers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_main_runs_successfully(mock_google_ads_client: MagicMock) -> None:
100100
modifier_hotel_day.hotel_check_in_day.day_of_week = mock_google_ads_client.enums.DayOfWeekEnum.MONDAY
101101
row2.ad_group_bid_modifier = modifier_hotel_day
102102

103-
mock_search_response_page = MagicMock()
103+
mock_search_response_page = MagicMock(spec=['results']) # Add spec
104104
mock_search_response_page.results = [row1, row2]
105105
mock_googleads_service.search.return_value = iter([mock_search_response_page])
106106

@@ -137,7 +137,7 @@ def test_main_runs_without_ad_group_id(mock_google_ads_client: MagicMock) -> Non
137137
modifier1.device.type_ = mock_google_ads_client.enums.DeviceEnum.TABLET
138138
row1.ad_group_bid_modifier = modifier1
139139

140-
mock_search_response_page = MagicMock()
140+
mock_search_response_page = MagicMock(spec=['results']) # Add spec
141141
mock_search_response_page.results = [row1]
142142
mock_googleads_service.search.return_value = iter([mock_search_response_page])
143143

0 commit comments

Comments
 (0)