feluelle commented on a change in pull request #6180: [AIRFLOW-5549] Extended
BQ GetDataOperator to handle query params
URL: https://github.com/apache/airflow/pull/6180#discussion_r329078685
##########
File path: tests/gcp/hooks/test_bigquery.py
##########
@@ -460,6 +460,49 @@ def test_insert_all_fail(self):
cursor.insert_all(project_id, dataset_id, table_id,
rows, fail_on_error=True)
+ def test_get_data(self):
+ expected_result = {
+ "kind": "bigquery#tableDataList",
+ "etag": "QB24gaarZFqaiu5jRyPiA==",
+ "totalRows": "30",
+ "pageToken": "BHSHJT3DRAFSSIAICAFCACSB77777777757SUAA=",
+ "rows": [
+ {
+ "f": [
+ {
+ "v": "219067803"
+ },
+ {
+ "v": "10000"
+ },
+ {
+ "v": "2019-01-09"
+ },
+ {
+ "v": "2019-01-11"
+ },
+ {
+ "v": "1565783983.395962"
+ }
+ ]
+ }
+ ]
+ }
+
+ project_id = 'your-project'
+ dataset_id = 'your_dataset'
+ table_id = 'table'
+
+ mock_service = mock.Mock()
+ with mock.patch.object(hook.BigQueryBaseCursor(mock_service,
project_id).service,
+ 'tabledata') as MockService:
+ MockService.return_value.list(
Review comment:
Do you really want to call the mock `(...)`? Or do you need just the return
value (`.return_value`)?
```suggestion
MockService.return_value.list.return_value.execute.return_value
= expected_result
```
In your current test you won't see the difference because you don't check
for calls of mocks.
I am always in favor of checking the mock calls of the objects you use for
example via `assert_called_once_with()`.
See the [docs](https://docs.python.org/3/library/unittest.mock.html) for
more information.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services