Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: include key metadata in Job representation (#964)
  • Loading branch information
plamut committed Sep 13, 2021
1 parent 9157537 commit acca1cb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions google/cloud/bigquery/job/base.py
Expand Up @@ -722,6 +722,14 @@ def cancelled(self):
and self.error_result.get("reason") == _STOPPED_REASON
)

def __repr__(self):
result = (
f"{self.__class__.__name__}<"
f"project={self.project}, location={self.location}, id={self.job_id}"
">"
)
return result


class _JobConfig(object):
"""Abstract base class for job configuration objects.
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/job/test_base.py
Expand Up @@ -1043,6 +1043,12 @@ def test_cancelled_w_error_result_w_stopped(self):

self.assertTrue(job.cancelled())

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


class Test_JobConfig(unittest.TestCase):
JOB_TYPE = "testing"
Expand Down

0 comments on commit acca1cb

Please sign in to comment.