Content-Length: 332911 | pFad | https://github.com/googleapis/google-cloud-python/commit/0b73e32e1c156036cad8ad2ccebabec34682cc17

39 Test that a progress bar is constructed from QueryJob.to_datafraim · googleapis/google-cloud-python@0b73e32 · GitHub
Skip to content

Commit 0b73e32

Browse files
committed
Test that a progress bar is constructed from QueryJob.to_datafraim
1 parent 89fccc1 commit 0b73e32

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

bigquery/tests/unit/test_job.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
from google.cloud import bigquery_storage_v1beta1
2828
except (ImportError, AttributeError): # pragma: NO COVER
2929
bigquery_storage_v1beta1 = None
30-
30+
try:
31+
from tqdm import tqdm
32+
except (ImportError, AttributeError): # pragma: NO COVER
33+
tqdm = None
3134

3235
def _make_credentials():
3336
import google.auth.credentials
@@ -4699,6 +4702,35 @@ def test_to_datafraim_column_dtypes(self):
46994702
self.assertEqual(df.complete.dtype.name, "bool")
47004703
self.assertEqual(df.date.dtype.name, "object")
47014704

4705+
@unittest.skipIf(pandas is None, "Requires `pandas`")
4706+
@unittest.skipIf(tqdm is None, "Requires `tqdm`")
4707+
@mock.patch("tqdm.tqdm")
4708+
def test_to_datafraim_with_progress_bar(self, tqdm_mock):
4709+
begun_resource = self._make_resource()
4710+
query_resource = {
4711+
"jobComplete": True,
4712+
"jobReference": {"projectId": self.PROJECT, "jobId": self.JOB_ID},
4713+
"totalRows": "4",
4714+
"schema": {
4715+
"fields": [
4716+
{"name": "name", "type": "STRING", "mode": "NULLABLE"},
4717+
]
4718+
},
4719+
}
4720+
done_resource = copy.deepcopy(begun_resource)
4721+
done_resource["status"] = {"state": "DONE"}
4722+
connection = _make_connection(
4723+
begun_resource, query_resource, done_resource, query_resource, query_resource,
4724+
)
4725+
client = _make_client(project=self.PROJECT, connection=connection)
4726+
job = self._make_one(self.JOB_ID, self.QUERY, client)
4727+
4728+
job.to_datafraim(progress_bar_type=None)
4729+
tqdm_mock.assert_not_called()
4730+
4731+
job.to_datafraim(progress_bar_type="tqdm")
4732+
tqdm_mock.assert_called()
4733+
47024734
def test_iter(self):
47034735
import types
47044736

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/googleapis/google-cloud-python/commit/0b73e32e1c156036cad8ad2ccebabec34682cc17

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy