Commit 17bef41
authored
test(bigquery-magics): make table_id parsing check version-agnostic (#17562)
> [!NOTE]
> These changes are at a high level unrelated. They are being submitted
as a single corrective action. Separating them leads to a chicken or the
egg set of failures (i.e. no one PR will pass all CI/CD tests with out
the other changes).
---
### test(bigquery-magics): make table_id parsing check version-agnostic
The unit test `test_bigquery_magic_query_variable_not_identifier` was
asserting that a specific error message ("must be a fully-qualified ID")
was in the stderr output.
However, in a recent versions of dependencies, this error message
changed (depending on whether tests were run under Python 3.10 or
3.11+). There is a key term that is common to both of the error
messages: `table_id`.
This change confirms that we get one of the two expected error messages
by checking for `table_id`, making it compatible regardless of which
runtime the tests run under.
---
### refactor(magics): replace fragile psutil socket check with client
close mock spy
The system test `test_bigquery_magic` was using `psutil` to count open
sockets before and after the test to detect leaks (i.e. ensure all the
system resources were released).
This approach proved to be fragile across different environments (e.g.,
Kokoro).
This change replaces the socket counting with a mock spy on
`google.cloud.bigquery.Client.close` to verify that the client is
explicitly closed, which is the intended mechanism for releasing system
resources.
---
### test(bigquery-magics): simplify IPython initialization in
deprecation test
The unit test `test_cell_magic_engine_bigframes_warning` in
`test_deprecation.py` was conditionally initializing IPython. Only one
of the code paths was being exercised so we were getting a coverage
issue.
This change simplifies the initialization by unconditionally calling
`start_ipython()` and assigning the returned instance to `ip` ensuring a
clean and consistent state for the test and avoiding the need for a
conditional check.1 parent e688531 commit 17bef41
3 files changed
Lines changed: 17 additions & 19 deletions
File tree
- packages/bigquery-magics/tests
- system
- unit/bigquery
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | | - | |
22 | | - | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
47 | 53 | | |
48 | 54 | | |
49 | 55 | | |
| |||
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2974 | 2974 | | |
2975 | 2975 | | |
2976 | 2976 | | |
2977 | | - | |
| 2977 | + | |
2978 | 2978 | | |
2979 | 2979 | | |
2980 | 2980 | | |
| |||
Lines changed: 2 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | 61 | | |
65 | 62 | | |
66 | 63 | | |
| |||
0 commit comments