Skip to content

Commit

Permalink
adds the diff feature and relevant tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas La Piana committed Aug 24, 2021
1 parent ee99620 commit e2c024d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions fidesctl/data/sample/system.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
system:
- organizationId: 1
fidesKey: "dataAnalyticSystem"
fidesKey: "dataAnalyticsSystem"
name: "Data Analytics System"
description: "A system used for analyzing customer behaviour."
systemType: "Service"
Expand All @@ -18,7 +18,7 @@ system:

- organizationId: 1
fidesKey: "customerDataSharingSystem"
name: "Customer Data Sharin System"
name: "Customer Data Sharing System"
description: "Share data about our users with third-parties."
systemType: "Service"
privacyDeclarations:
Expand Down
7 changes: 5 additions & 2 deletions fidesctl/src/fidesctl/core/apply.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module handles the logic required for applying manifest files to the server."""
from pprint import pprint
from typing import Dict, List, Tuple, Optional, Iterable

from deepdiff import DeepDiff
Expand Down Expand Up @@ -41,12 +42,14 @@ def sort_create_update_unchanged(
unchanged_list.append(manifest_object)
else:
if diff:
print(DeepDiff(server_object, manifest_object))
print(f"\nUpdated object with fidesKey: {manifest_object.fidesKey}")
pprint(DeepDiff(server_object, manifest_object))
update_list.append(manifest_object)

else:
if diff:
print(manifest_object)
print(f"\nNew object with fidesKey: {manifest_object.fidesKey}")
pprint(manifest_object)
create_list.append(manifest_object)

return create_list, update_list, unchanged_list
Expand Down
18 changes: 18 additions & 0 deletions fidesctl/tests/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ def test_dry_apply(test_config_path: str, test_cli_runner: CliRunner):
assert result.exit_code == 0


@pytest.mark.integration
def test_diff_apply(test_config_path: str, test_cli_runner: CliRunner):
result = test_cli_runner.invoke(
cli, ["-f", test_config_path, "apply", "data/sample/", "--diff"]
)
print(result.output)
assert result.exit_code == 0


@pytest.mark.integration
def test_dry_diff_apply(test_config_path: str, test_cli_runner: CliRunner):
result = test_cli_runner.invoke(
cli, ["-f", test_config_path, "apply", "data/sample/", "--dry", "--diff"]
)
print(result.output)
assert result.exit_code == 0


@pytest.mark.integration
def test_find(test_config_path: str, test_cli_runner: CliRunner):
result = test_cli_runner.invoke(
Expand Down

0 comments on commit e2c024d

Please sign in to comment.