-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(bigquery): make rowIterator._to_dataframe_iterable public #10017
feat(bigquery): make rowIterator._to_dataframe_iterable public #10017
Conversation
bigquery/tests/unit/test_table.py
Outdated
row_iterator = self._make_one( | ||
_mock_client(), api_request, path, schema, page_size=1, max_results=5 | ||
) | ||
df = row_iterator.to_dataframe_iterable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is a generator, use a plural for the variable name dfs
or dataframes
.
bigquery/tests/unit/test_table.py
Outdated
|
||
self.assertIsInstance(df, types.GeneratorType) | ||
|
||
a = next(df) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a
is a Pandas DataFrame, so df
or dataframe
would be a more appropriate name.
bigquery/tests/unit/test_table.py
Outdated
{"f": [{"v": "Bhettye Rhubble"}, {"v": "27"}]}, | ||
] | ||
path = "/foo" | ||
api_request = mock.Mock(return_value={"rows": rows}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to see side_effect
used to test with multiple pages.
bigquery/tests/unit/test_table.py
Outdated
api_request = mock.Mock(return_value={"rows": rows}) | ||
row_iterator = self._make_one(_mock_client(), api_request, path, schema) | ||
|
||
with self.assertRaises(ValueError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use pytest.raises
and match="pandas"
to make sure that the ValueError
occurs because of the missing pandas dependency.
bigquery/tests/unit/test_table.py
Outdated
self.assertEqual(df_1.age.dtype.name, "int64") | ||
self.assertEqual(len(df_1), 1) # verify the number of rows | ||
self.assertEqual( | ||
df_1.name._get_value(0), "Bengt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use _get_value(0)
instead of df_1["name"][0]
?
Concerned about use of private _get_value in unit tests.
@tswast PTAL. |
Fixes #7339