Skip to content

Commit acca1cb

Browse files
authored
feat: include key metadata in Job representation (#964)
1 parent 9157537 commit acca1cb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

google/cloud/bigquery/job/base.py

+8
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,14 @@ def cancelled(self):
722722
and self.error_result.get("reason") == _STOPPED_REASON
723723
)
724724

725+
def __repr__(self):
726+
result = (
727+
f"{self.__class__.__name__}<"
728+
f"project={self.project}, location={self.location}, id={self.job_id}"
729+
">"
730+
)
731+
return result
732+
725733

726734
class _JobConfig(object):
727735
"""Abstract base class for job configuration objects.

tests/unit/job/test_base.py

+6
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,12 @@ def test_cancelled_w_error_result_w_stopped(self):
10431043

10441044
self.assertTrue(job.cancelled())
10451045

1046+
def test_repr(self):
1047+
client = _make_client(project="project-foo")
1048+
job = self._make_one("job-99", client)
1049+
job._properties.setdefault("jobReference", {})["location"] = "ABC"
1050+
assert repr(job) == "_AsyncJob<project=project-foo, location=ABC, id=job-99>"
1051+
10461052

10471053
class Test_JobConfig(unittest.TestCase):
10481054
JOB_TYPE = "testing"

0 commit comments

Comments
 (0)