From e864608fb80290ae3209e5f743464368dd02eac7 Mon Sep 17 00:00:00 2001 From: Matthew Jadud Date: Wed, 27 Mar 2024 14:47:07 -0400 Subject: [PATCH] Ignore named functions when processing named ranges (#3566) * Ignore named functions when processing named ranges Remove exception/error on named functions We have discovered that some accounting packages add named functions to the defined names in a workbook. These crash our code, because we assumed all named things were ranges. Named functions do not (for example) have cell references. This change leaves a logging statement in place for this situation. We no longer report an error to the user. Why? Because the user may not know the functions even exist. We will still reject workbooks that have named ranges we cannot recognize. We still only pull data from named ranges we recognize. But, we will allow the named functions to exist. * skipped no destination found test --------- Co-authored-by: Hassan D. M. Sambo --- backend/audit/intakelib/intermediate_representation.py | 2 +- backend/audit/test_intakelib.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/audit/intakelib/intermediate_representation.py b/backend/audit/intakelib/intermediate_representation.py index 24a3f3c824..2ad898aea2 100644 --- a/backend/audit/intakelib/intermediate_representation.py +++ b/backend/audit/intakelib/intermediate_representation.py @@ -282,7 +282,7 @@ def extract_workbook_as_ir(file): process_destination(dn, title, coord, sheets_by_name, workbook) except StopIteration: logger.info(f"No destinations found for {named_range_name}.") - raise_modified_workbook(WORKBOOK_MODIFIED_ERROR) + # raise_modified_workbook(WORKBOOK_MODIFIED_ERROR) # Build the IR, which is a list of sheets. sheets = [] diff --git a/backend/audit/test_intakelib.py b/backend/audit/test_intakelib.py index b391d82232..a4c884982d 100644 --- a/backend/audit/test_intakelib.py +++ b/backend/audit/test_intakelib.py @@ -1,3 +1,4 @@ +import unittest from django.test import SimpleTestCase from copy import deepcopy from audit.intakelib.intermediate_representation import ( @@ -144,6 +145,9 @@ def test_extract_with_ref_error(self, mock_open_workbook): with self.assertRaises(ValidationError): extract_workbook_as_ir("dummy_file_with_ref_error") + @unittest.skip( + "Skipping this test as we have turned off check for no destination found in extract_workbook_as_ir." + ) @patch("audit.intakelib.intermediate_representation._open_workbook") def test_no_destination_found(self, mock_open_workbook): """Test handling of a workbook with no destinations found for a named range."""