From c4a8d86d8c111c747df230e3ba41baf6ed5063fd Mon Sep 17 00:00:00 2001 From: SteveDMurphy Date: Tue, 12 Jul 2022 16:09:32 -0400 Subject: [PATCH] clean up further test failures and visualize sort --- .../docs/language/taxonomy/data_categories.md | 2 +- src/fidesctl/core/visualize.py | 3 +- tests/core/test_evaluate.py | 4 +-- tests/core/test_export.py | 4 +-- tests/core/test_visualize.py | 26 ++++++++--------- tests/data/sample_hierarchy_figures.json | 28 +++++++++---------- 6 files changed, 34 insertions(+), 33 deletions(-) diff --git a/docs/fides/docs/language/taxonomy/data_categories.md b/docs/fides/docs/language/taxonomy/data_categories.md index 618dfa5211..4686c9807b 100644 --- a/docs/fides/docs/language/taxonomy/data_categories.md +++ b/docs/fides/docs/language/taxonomy/data_categories.md @@ -39,7 +39,7 @@ The fides key of the organization to which this Data Category belongs. ## Top Level Data Categories -There are three top-level categories: +There are two top-level categories: | Label | Parent Key | Description | | --- | --- | --- | diff --git a/src/fidesctl/core/visualize.py b/src/fidesctl/core/visualize.py index 708ea48ce1..5cd68e1d60 100644 --- a/src/fidesctl/core/visualize.py +++ b/src/fidesctl/core/visualize.py @@ -34,7 +34,8 @@ def hierarchy_figures( fides_key_dict = {} # build assets/relationships for figures - for i, category in enumerate(categories): + sorted_categories = sorted(categories, key=lambda i: i[FIDES_KEY_NAME]) + for i, category in enumerate(sorted_categories): # get sunburst labels and parents labels.append(category[FIDES_KEY_NAME]) parents.append(category[FIDES_PARENT_NAME]) diff --git a/tests/core/test_evaluate.py b/tests/core/test_evaluate.py index 9f82c8503d..d2087d3f32 100644 --- a/tests/core/test_evaluate.py +++ b/tests/core/test_evaluate.py @@ -110,7 +110,7 @@ def test_populate_referenced_keys_recursively(test_config: FidesctlConfig) -> No privacy_declarations=[ PrivacyDeclaration( name="privacy_declaration_1", - data_categories=["account.contact.email"], + data_categories=["user.contact.email"], data_use="provide.service", data_qualifier="aggregated.anonymized", data_subjects=["customer"], @@ -128,7 +128,7 @@ def test_populate_referenced_keys_recursively(test_config: FidesctlConfig) -> No category.fides_key for category in result_taxonomy.data_category ] assert sorted(populated_categories) == sorted( - ["account.contact.email", "account.contact", "account"] + ["user.contact.email", "user.contact", "user"] ) populated_data_uses = [data_use.fides_key for data_use in result_taxonomy.data_use] diff --git a/tests/core/test_export.py b/tests/core/test_export.py index f079703485..ba6d3b4b35 100644 --- a/tests/core/test_export.py +++ b/tests/core/test_export.py @@ -30,8 +30,8 @@ def test_sample_system_taxonomy() -> Generator: PrivacyDeclaration( name="privacy_declaration_1", data_categories=[ - "account.contact.email", - "account.contact.name", + "user.contact.email", + "user.contact.name", ], data_use="provide.service", data_qualifier="aggregated.anonymized", diff --git a/tests/core/test_visualize.py b/tests/core/test_visualize.py index 324380014c..ec4b4d5d62 100644 --- a/tests/core/test_visualize.py +++ b/tests/core/test_visualize.py @@ -14,25 +14,25 @@ def sample_categories_list() -> List: return [ { - "fides_key": "account", + "fides_key": "user", "organization_fides_key": "default_organization", - "name": "Account Data", - "description": "Data related to a system account.", + "name": "User Data", + "description": "Data related to a user.", "parent_key": None, }, { - "fides_key": "account.contact", + "fides_key": "user.contact", "organization_fides_key": "default_organization", - "name": "Account Contact Data", - "description": "Contact data related to a system account.", - "parent_key": "account", + "name": "User Contact Data", + "description": "Contact data related to a user.", + "parent_key": "user", }, { - "fides_key": "account.contact.city", + "fides_key": "user.contact.address", "organization_fides_key": "default_organization", - "name": "Account City", - "description": "Account's city level address data.", - "parent_key": "account.contact", + "name": "User Address", + "description": "User address data.", + "parent_key": "user.contact", }, ] @@ -49,7 +49,7 @@ def test_hierarchy_figures(sample_categories_list: List) -> None: @pytest.mark.unit def test_convert_categories_to_nested_dict(sample_categories_list: List) -> None: - expected_conversion: Dict = {"account": {"contact": {"city": {}}}} + expected_conversion: Dict = {"user": {"contact": {"address": {}}}} assert ( visualize.convert_categories_to_nested_dict(sample_categories_list) == expected_conversion @@ -58,7 +58,7 @@ def test_convert_categories_to_nested_dict(sample_categories_list: List) -> None @pytest.mark.unit def test_nested_categories_to_html_list(sample_categories_list: List) -> None: - expected_html_list = "

Fides Data Category Hierarchy

\n
  • account
  • \n " + expected_html_list = "

    Fides Data Category Hierarchy

    \n
  • user
  • \n " assert ( visualize.nested_categories_to_html_list( sample_categories_list, resource_type="data_category" diff --git a/tests/data/sample_hierarchy_figures.json b/tests/data/sample_hierarchy_figures.json index 2f77287f8f..1834144304 100644 --- a/tests/data/sample_hierarchy_figures.json +++ b/tests/data/sample_hierarchy_figures.json @@ -3,14 +3,14 @@ { "hoverinfo": "skip", "labels": [ - "account", - "account.contact", - "account.contact.city" + "user", + "user.contact", + "user.contact.address" ], "parents": [ null, - "account", - "account.contact" + "user", + "user.contact" ], "type": "sunburst" }, @@ -33,9 +33,9 @@ "node": { "color": "blue", "label": [ - "account", - "account.contact", - "account.contact.city" + "user", + "user.contact", + "user.contact.address" ], "line": { "color": "black", @@ -52,14 +52,14 @@ { "hoverinfo": "skip", "labels": [ - "account", - "account.contact", - "account.contact.city" + "user", + "user.contact", + "user.contact.address" ], "parents": [ null, - "account", - "account.contact" + "user", + "user.contact" ], "type": "icicle", "visible": false @@ -934,4 +934,4 @@ } ] } -} \ No newline at end of file +}