Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
eastandwestwind committed Dec 18, 2024
1 parent 0519f4d commit 4143e08
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 68 deletions.
20 changes: 13 additions & 7 deletions tests/fixtures/bigquery_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ def bigquery_enterprise_test_dataset_config(

@pytest.fixture
def bigquery_enterprise_test_dataset_config_with_partitioning_meta(
bigquery_enterprise_connection_config: ConnectionConfig,
db: Session,
example_datasets: List[Dict],
bigquery_enterprise_connection_config: ConnectionConfig,
db: Session,
example_datasets: List[Dict],
) -> Generator:
bigquery_enterprise_dataset = example_datasets[16]
fides_key = bigquery_enterprise_dataset["fides_key"]
Expand All @@ -220,7 +220,9 @@ def bigquery_enterprise_test_dataset_config_with_partitioning_meta(
for collection in bigquery_enterprise_dataset["collections"]
if collection["name"] == "stackoverflow_posts_partitioned"
)
bigquery_enterprise_dataset["collections"].remove(stackoverflow_posts_partitioned_collection)
bigquery_enterprise_dataset["collections"].remove(
stackoverflow_posts_partitioned_collection
)
stackoverflow_posts_partitioned_collection["fides_meta"] = {
"partitioning": {
"where_clauses": [
Expand All @@ -229,7 +231,9 @@ def bigquery_enterprise_test_dataset_config_with_partitioning_meta(
]
}
}
bigquery_enterprise_dataset["collections"].append(stackoverflow_posts_partitioned_collection)
bigquery_enterprise_dataset["collections"].append(
stackoverflow_posts_partitioned_collection
)

bigquery_enterprise_connection_config.save(db=db)

Expand Down Expand Up @@ -594,7 +598,7 @@ def bigquery_enterprise_resources(

@pytest.fixture(scope="function")
def bigquery_enterprise_resources_with_partitioning(
bigquery_enterprise_test_dataset_config_with_partitioning_meta,
bigquery_enterprise_test_dataset_config_with_partitioning_meta,
):
bigquery_connection_config = (
bigquery_enterprise_test_dataset_config_with_partitioning_meta.connection_config
Expand Down Expand Up @@ -712,7 +716,9 @@ def bigquery_test_engine(bigquery_keyfile_creds) -> Generator:
engine.dispose()


def seed_bigquery_enterprise_integration_db(bigquery_enterprise_test_dataset_config) -> None:
def seed_bigquery_enterprise_integration_db(
bigquery_enterprise_test_dataset_config,
) -> None:
"""
Currently unused.
This helper function has already been run once, and data has been populated in the test BigQuery enterprise dataset.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ def test_access_request(
run_privacy_request_task,
):
request.getfixturevalue(dsr_version) # REQUIRED to test both DSR 3.0 and 2.0
request.getfixturevalue(bigquery_fixtures) # required to test partitioning and non-partitioned tables
request.getfixturevalue(
bigquery_fixtures
) # required to test partitioning and non-partitioned tables

customer_email = "[email protected]"
user_id = (
Expand Down Expand Up @@ -114,7 +116,9 @@ def test_access_request(
len(
[
post["title"]
for post in results["enterprise_dsr_testing:stackoverflow_posts_partitioned"]
for post in results[
"enterprise_dsr_testing:stackoverflow_posts_partitioned"
]
]
)
== 30
Expand Down Expand Up @@ -158,7 +162,7 @@ def test_access_request(
"bigquery_fixtures",
[
"bigquery_enterprise_resources",
"bigquery_enterprise_resources_with_partitioning"
"bigquery_enterprise_resources_with_partitioning",
],
)
def test_erasure_request(
Expand Down Expand Up @@ -229,7 +233,9 @@ def test_erasure_request(
len(
[
post["title"]
for post in results["enterprise_dsr_testing:stackoverflow_posts_partitioned"]
for post in results[
"enterprise_dsr_testing:stackoverflow_posts_partitioned"
]
]
)
== 1
Expand Down Expand Up @@ -297,16 +303,16 @@ def test_erasure_request(
)
@mock.patch("fides.api.models.privacy_request.PrivacyRequest.trigger_policy_webhook")
def test_access_request_multiple_custom_identities(
trigger_webhook_mock,
bigquery_enterprise_test_dataset_config,
db,
cache,
policy,
dsr_version,
request,
policy_pre_execution_webhooks,
policy_post_execution_webhooks,
run_privacy_request_task,
trigger_webhook_mock,
bigquery_enterprise_test_dataset_config,
db,
cache,
policy,
dsr_version,
request,
policy_pre_execution_webhooks,
policy_post_execution_webhooks,
run_privacy_request_task,
):
request.getfixturevalue(dsr_version) # REQUIRED to test both DSR 3.0 and 2.0

Expand Down Expand Up @@ -346,28 +352,30 @@ def test_access_request_multiple_custom_identities(
assert user_details["id"] == user_id

assert (
len(
[
comment["user_id"]
for comment in results["enterprise_dsr_testing:comments"]
]
)
== 16
len(
[
comment["user_id"]
for comment in results["enterprise_dsr_testing:comments"]
]
)
== 16
)
assert (
len(
[post["user_id"] for post in results["enterprise_dsr_testing:post_history"]]
)
== 39
len(
[post["user_id"] for post in results["enterprise_dsr_testing:post_history"]]
)
== 39
)
assert (
len(
[
post["title"]
for post in results["enterprise_dsr_testing:stackoverflow_posts_partitioned"]
len(
[
post["title"]
for post in results[
"enterprise_dsr_testing:stackoverflow_posts_partitioned"
]
)
== 30
]
)
== 30
)

log_id = pr.execution_logs[0].id
Expand All @@ -376,8 +384,8 @@ def test_access_request_multiple_custom_identities(
finished_audit_log: AuditLog = AuditLog.filter(
db=db,
conditions=(
(AuditLog.privacy_request_id == pr_id)
& (AuditLog.action == AuditLogAction.finished)
(AuditLog.privacy_request_id == pr_id)
& (AuditLog.action == AuditLogAction.finished)
),
).first()

Expand Down Expand Up @@ -408,18 +416,18 @@ def test_access_request_multiple_custom_identities(
"bigquery_fixtures",
[
"bigquery_enterprise_resources",
"bigquery_enterprise_resources_with_partitioning"
"bigquery_enterprise_resources_with_partitioning",
],
)
def test_erasure_request_multiple_custom_identities(
db,
request,
policy,
cache,
dsr_version,
bigquery_fixtures,
bigquery_enterprise_erasure_policy,
run_privacy_request_task,
db,
request,
policy,
cache,
dsr_version,
bigquery_fixtures,
bigquery_enterprise_erasure_policy,
run_privacy_request_task,
):
request.getfixturevalue(dsr_version) # REQUIRED to test both DSR 3.0 and 2.0
bigquery_enterprise_resources = request.getfixturevalue(bigquery_fixtures)
Expand Down Expand Up @@ -460,28 +468,30 @@ def test_erasure_request_multiple_custom_identities(
assert user_details["id"] == user_id

assert (
len(
[
comment["user_id"]
for comment in results["enterprise_dsr_testing:comments"]
]
)
== 1
len(
[
comment["user_id"]
for comment in results["enterprise_dsr_testing:comments"]
]
)
== 1
)
assert (
len(
[post["user_id"] for post in results["enterprise_dsr_testing:post_history"]]
)
== 1
len(
[post["user_id"] for post in results["enterprise_dsr_testing:post_history"]]
)
== 1
)
assert (
len(
[
post["title"]
for post in results["enterprise_dsr_testing:stackoverflow_posts_partitioned"]
len(
[
post["title"]
for post in results[
"enterprise_dsr_testing:stackoverflow_posts_partitioned"
]
)
== 1
]
)
== 1
)

data = {
Expand Down Expand Up @@ -525,7 +535,7 @@ def test_erasure_request_multiple_custom_identities(
res = connection.execute(stmt).all()
for row in res:
assert (
row.owner_user_id == bigquery_enterprise_resources["user_id"]
row.owner_user_id == bigquery_enterprise_resources["user_id"]
) # not targeted by policy
assert row.owner_display_name is None
assert row.body is None
Expand All @@ -534,4 +544,4 @@ def test_erasure_request_multiple_custom_identities(
res = connection.execute(stmt).all()
for row in res:
assert row.display_name is None
assert row.location is None
assert row.location is None

0 comments on commit 4143e08

Please sign in to comment.