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_r329085382
##########
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(
+ dataset_id=dataset_id, table_id=table_id).execute.return_value
= expected_result
+ result = hook.BigQueryBaseCursor(
+ mock_service, project_id).get_tabledata(
+ dataset_id=dataset_id, table_id=table_id)
+ self.assertEqual(result, expected_result)
Review comment:
I try to split up my test into three sections.
1. Setup (mostly via annotations/decorator)
2. The actual call
3. The assertion
and put one space in between each section like so
https://github.com/apache/airflow/blob/master/tests/contrib/hooks/test_imap_hook.py
so that you can directly see what the test is trying to cover.
----------------------------------------------------------------
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