def test_excel_bulkEntities_withClassifications(): temp_filepath = "./temp_test_excel_bulkEntitiesWithClassifications.xlsx" ec = ExcelConfiguration() reader = ExcelReader(ec) max_cols = len(ExcelReader.TEMPLATE_HEADERS["BulkEntities"]) # "typeName", "name", # "qualifiedName", "classifications" json_rows = [[ "demoType", "entityNameABC", "qualifiedNameofEntityNameABC", "PII" ], [ "demoType", "entityNameGHI", "qualifiedNameofEntityNameGHI", "PII;CLASS2" ]] setup_workbook(temp_filepath, "BulkEntities", max_cols, json_rows) results = reader.parse_bulk_entities(temp_filepath) try: assert ("entities" in results) assert (len(results["entities"]) == 2) abc = results["entities"][0] ghi = results["entities"][1] assert (len(abc["classifications"]) == 1) assert (len(ghi["classifications"]) == 2) assert (abc["classifications"][0]["typeName"] == "PII") ghi_classification_types = set( [x["typeName"] for x in ghi["classifications"]]) assert (set(["PII", "CLASS2"]) == ghi_classification_types) finally: remove_workbook(temp_filepath)
def test_excel_bulkEntities_meanings_relationships(): temp_filepath = "./temp_test_excel_bulkEntitieswithMeanings.xlsx" ec = ExcelConfiguration() reader = ExcelReader(ec) headers = ExcelReader.TEMPLATE_HEADERS["BulkEntities"] + \ ["[Relationship] meanings"] # "typeName", "name", # "qualifiedName", "classifications" # "[Relationship] meanings" json_rows = [ ["demoType", "entityNameABC", "qualifiedNameofEntityNameABC", None, None ], ["demoType", "entityNameGHI", "qualifiedNameofEntityNameGHI", None, "termA" ], ["demoType", "entityNameXYZ", "qualifiedNameofEntityNameXYZ", None, "term1;term2" ] ] setup_workbook_custom_sheet( temp_filepath, "BulkEntities", headers, json_rows) results = reader.parse_bulk_entities(temp_filepath) try: abc = results["entities"][0] ghi = results["entities"][1] xyz = results["entities"][2] assert("meanings" not in abc["relationshipAttributes"]) assert("meanings" in ghi["relationshipAttributes"]) ghi_terms = ghi["relationshipAttributes"]["meanings"] xyz_terms = xyz["relationshipAttributes"]["meanings"] assert(len(ghi_terms) == 1) assert(len(xyz_terms) == 2) finally: remove_workbook(temp_filepath)
def test_excel_bulkEntities(): temp_filepath = "./temp_test_excel_bulkEntities.xlsx" ec = ExcelConfiguration() reader = ExcelReader(ec) max_cols = len(ExcelReader.TEMPLATE_HEADERS["BulkEntities"]) # "typeName", "name", # "qualifiedName", "classifications" json_rows = [[ "demoType", "entityNameABC", "qualifiedNameofEntityNameABC", None ], ["demoType", "entityNameGHI", "qualifiedNameofEntityNameGHI", None]] setup_workbook(temp_filepath, "BulkEntities", max_cols, json_rows) results = reader.parse_bulk_entities(temp_filepath) try: assert ("entities" in results) assert (len(results["entities"]) == 2) finally: remove_workbook(temp_filepath)
def test_excel_bulkEntities_dynamicAttributes(): temp_filepath = "./temp_test_excel_bulkEntitieswithAttributes.xlsx" ec = ExcelConfiguration() reader = ExcelReader(ec) headers = ExcelReader.TEMPLATE_HEADERS["BulkEntities"] + \ ["attrib1", "attrib2"] # "typeName", "name", # "qualifiedName", "classifications" # "attrib1", "attrib2" json_rows = [ ["demoType", "entityNameABC", "qualifiedNameofEntityNameABC", None, None, "abc" ], ["demoType", "entityNameGHI", "qualifiedNameofEntityNameGHI", None, "ghi", "abc2" ] ] setup_workbook_custom_sheet( temp_filepath, "BulkEntities", headers, json_rows) results = reader.parse_bulk_entities(temp_filepath) try: assert("entities" in results) assert(len(results["entities"]) == 2) abc = results["entities"][0] ghi = results["entities"][1] assert("attrib1" not in abc["attributes"]) assert("attrib2" in abc["attributes"]) assert(abc["attributes"]["attrib2"] == "abc") assert("attrib1" in ghi["attributes"]) assert("attrib2" in ghi["attributes"]) assert(ghi["attributes"]["attrib2"] == "abc2") assert(ghi["attributes"]["attrib1"] == "ghi") finally: remove_workbook(temp_filepath)