Skip to content

Commit 6ab2c3c

Browse files
committed
remove trailing whitespace and add test assertions
1 parent 7687693 commit 6ab2c3c

File tree

2 files changed

+51
-15
lines changed

2 files changed

+51
-15
lines changed

google/cloud/bigquery/dataset.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,6 @@ def entity_id(self) -> Optional[Union[Dict[str, Any], str]]:
507507
def __eq__(self, other):
508508
if not isinstance(other, AccessEntry):
509509
return NotImplemented
510-
511510
return (
512511
self.role == other.role
513512
and self.entity_type == other.entity_type
@@ -571,7 +570,6 @@ def to_api_repr(self):
571570
resource[k] = v
572571

573572
return resource
574-
575573

576574
@classmethod
577575
def from_api_repr(cls, resource: dict) -> "AccessEntry":
@@ -585,7 +583,6 @@ def from_api_repr(cls, resource: dict) -> "AccessEntry":
585583
google.cloud.bigquery.dataset.AccessEntry:
586584
Access entry parsed from ``resource``.
587585
"""
588-
589586
role = resource.get("role")
590587
condition = None
591588
if "condition" in resource:
@@ -595,7 +592,7 @@ def from_api_repr(cls, resource: dict) -> "AccessEntry":
595592
entity_id = None
596593

597594
for key, value in resource.items():
598-
if key in ("role", "condition"):
595+
if key in ("role","condition"):
599596
continue
600597
entity_type = key
601598
entity_id = value

tests/unit/test_dataset.py

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,26 +1767,65 @@ def test__hash__with_minimal_inputs(self):
17671767
description=None,
17681768
)
17691769
assert hash(cond1) is not None
1770-
1770+
17711771
def test_access_entry_view_equality(self):
1772-
1772+
17731773
from google.cloud import bigquery
1774-
1774+
17751775
entry1 = bigquery.dataset.AccessEntry(
17761776
entity_type="view",
17771777
entity_id={
1778-
"projectId": "my_project",
1779-
"datasetId": "my_dataset",
1780-
"tableId": "my_table",
1778+
"projectId":"my_project",
1779+
"datasetId":"my_dataset",
1780+
"tableId":"my_table",
17811781
},
17821782
)
17831783
entry2 = bigquery.dataset.AccessEntry.from_api_repr({
1784-
"view": {
1785-
"projectId": "my_project",
1786-
"datasetId": "my_dataset",
1787-
"tableId": "my_table",
1784+
"view":{
1785+
"projectId":"my_project",
1786+
"datasetId":"my_dataset",
1787+
"tableId":"my_table",
17881788
}
17891789
})
17901790

1791-
assert entry1 == entry2
1791+
entry3 = bigquery.dataset.AccessEntry(
1792+
entity_type="routine",
1793+
entity_id={
1794+
"projectId":"my_project",
1795+
"datasetId":"my_dataset",
1796+
"routineId":"my_routine",
1797+
},
1798+
)
17921799

1800+
entry4 = bigquery.dataset.AccessEntry.from_api_repr({
1801+
"routine":{
1802+
"projectId":"my_project",
1803+
"datasetId":"my_dataset",
1804+
"routineId":"my_routine",
1805+
}
1806+
})
1807+
1808+
entry5 = bigquery.dataset.AccessEntry(
1809+
entity_type="dataset",
1810+
entity_id={
1811+
"dataset": {
1812+
"projectId":"my_project",
1813+
"datasetId":"my_dataset",
1814+
},
1815+
"target_types":"VIEWS",
1816+
},
1817+
)
1818+
1819+
entry6 = bigquery.dataset.AccessEntry.from_api_repr({
1820+
"dataset":{
1821+
"dataset":{
1822+
"projectId":"my_project",
1823+
"datasetId":"my_dataset",
1824+
},
1825+
"target_types":"VIEWS",
1826+
}
1827+
})
1828+
1829+
assert entry1 == entry2
1830+
assert entry3 == entry4
1831+
assert entry5 == entry6

0 commit comments

Comments
 (0)