Commit e31919a
Fix: Resolve path and mock assertions in test_campaign_report_to_csv.py
This commit addresses remaining errors in
`examples/misc/tests/test_campaign_report_to_csv.py`:
1. **Success Path Tests (`test_main_success_with_headers`, `test_main_success_without_headers`):**
* I corrected assertions for `builtins.open` calls. The tests now
mock `os.path.abspath` to ensure a predictable absolute path is
generated by the script. The `open()` call is then asserted using
this controlled absolute path and matching your script's arguments
(e.g., `newline=""`, no `encoding`). This resolves AssertionErrors
where the expected relative path did not match the actual absolute path.
* These tests were previously updated to use concrete helper classes
for mock API response data and to correctly assert `search_stream` calls.
2. **Argument Parsing Tests (`test_argument_parsing`, `test_argument_parsing_no_headers_flag`):**
* These tests were previously refactored to use a helper method
(`_simulate_script_main_block`) that directly simulates your script's
`if __name__ == "__main__":` block. This resolved
TypeErrors related to `os.path.join`.
3. **`RecursionError` (from `test_main_google_ads_exception`):**
* This was previously resolved by updates to `test_utils.py` which
simplified the creation of mock `GoogleAdsException` instances.
All known FAILURES for `test_campaign_report_to_csv.py` should now be
addressed.1 parent ecbcad6 commit e31919a
1 file changed
Lines changed: 11 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| 113 | + | |
112 | 114 | | |
113 | | - | |
| 115 | + | |
114 | 116 | | |
| 117 | + | |
115 | 118 | | |
116 | 119 | | |
117 | 120 | | |
| |||
173 | 176 | | |
174 | 177 | | |
175 | 178 | | |
176 | | - | |
| 179 | + | |
| 180 | + | |
177 | 181 | | |
178 | 182 | | |
179 | 183 | | |
| |||
217 | 221 | | |
218 | 222 | | |
219 | 223 | | |
| 224 | + | |
220 | 225 | | |
221 | | - | |
| 226 | + | |
222 | 227 | | |
| 228 | + | |
223 | 229 | | |
224 | 230 | | |
225 | 231 | | |
| |||
242 | 248 | | |
243 | 249 | | |
244 | 250 | | |
245 | | - | |
| 251 | + | |
| 252 | + | |
246 | 253 | | |
247 | 254 | | |
248 | 255 | | |
| |||
0 commit comments