From 561c0531fe49b0d87e825e34bc059c5e7570be10 Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Fri, 4 Mar 2016 16:06:49 -0700 Subject: [PATCH 01/16] Broke DATE_BOUNDS_DICT into a seperate cvs file to make it easier to debug --- dqc_us_rules/dqc_us_0006.py | 26 ++++++++++++++----- .../DQC_US_0006/dqc_06_date_bounds.csv | 5 ++++ tests/unit_tests/test_dqc_us_0006.py | 24 ++++++++++++++--- 3 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 dqc_us_rules/resources/DQC_US_0006/dqc_06_date_bounds.csv diff --git a/dqc_us_rules/dqc_us_0006.py b/dqc_us_rules/dqc_us_0006.py index 400d07a6a7..4041a8fcd6 100644 --- a/dqc_us_rules/dqc_us_0006.py +++ b/dqc_us_rules/dqc_us_0006.py @@ -4,19 +4,16 @@ from collections import defaultdict from datetime import timedelta from .util import facts, messages +import csv +import os CHECK_TYPES = ['textBlockItemType'] CHECK_DEI = ['AmendmentDescription', 'AmendmentFlag', 'CurrentFiscalYearEndDate', 'DocumentPeriodEndDate', 'DocumentFiscalYearFocus', 'DocumentFiscalPeriodFocus', 'DocumentType', 'EntityRegistrantName', 'EntityCentralIndexKey', 'EntityFilerCategory'] -DATE_BOUNDS_DICT = { - "FY": {"min": 340, "max": 390}, - "Q1": {"min": 65, "max": 115}, - "Q2": {"min": 155, "max": 205}, - "Q3": {"min": 245, "max": 295} -} _CODE_NAME = 'DQC.US.0006' _RULE_VERSION = '1.0' +_DEFAULT_DATE_BOUNDS_FILE = os.path.join(os.path.dirname(__file__), 'resources', 'DQC_US_0006', 'dqc_06_date_bounds.csv') def validate_dates_within_periods(val): @@ -24,6 +21,7 @@ def validate_dates_within_periods(val): Check Date Ranges are within expected values for the fiscal focus period """ + DATE_BOUNDS_DICT = date_bounds_from_csv() doc_type = facts.lookup_dei_facts('DocumentType', val.modelXbrl) if len(doc_type) != 1 or 'T' in doc_type[0].xValue: # If it is a transitional document, or there is more than one document type declared, we will not run this check. @@ -37,6 +35,7 @@ def validate_dates_within_periods(val): ruleVersion=_RULE_VERSION) + def _date_range_check(check_types, check_dei, date_bounds_dict, modelXbrl): """ Takes two lists of fact names, a dict of date boundaries and modelXbrl and then compiles a list of all @@ -44,6 +43,7 @@ def _date_range_check(check_types, check_dei, date_bounds_dict, modelXbrl): date span to the date boundaries for the corresponding document period focus. Any facts with spans less than or larger than the supplied boundaries are returned in a dict based on the document period focus. """ + print("date range check") facts_in_error = defaultdict(list) list_of_facts = facts.LegalEntityAxis_facts_by_member(facts.get_facts_with_type(check_types, modelXbrl)) list_of_facts = _dict_list_update(list_of_facts, (facts.LegalEntityAxis_facts_by_member(facts.get_facts_dei(check_dei, modelXbrl)))) @@ -75,6 +75,20 @@ def _dict_list_update(dict_a, dict_b): dict_a[key].extend(val) return dict_a +def date_bounds_from_csv(): + """ + Returns a map of {time_period: {'min':min_value,'max':max_value}} + ex: date_bounds_from_csv()['Q1'] = {'min':65,'max':115} + + :returns: A map of {time_period: {'min':min_value,'max':max_value}}. + """ + with open(_DEFAULT_DATE_BOUNDS_FILE, 'r') as f: + reader = csv.reader(f) + date_bounds_dict = {} + next(reader, None) + for row in reader: + date_bounds_dict[row[0]]={'min':int(row[1]),'max':int(row[2])} + return date_bounds_dict __pluginInfo__ = { 'name': _CODE_NAME, diff --git a/dqc_us_rules/resources/DQC_US_0006/dqc_06_date_bounds.csv b/dqc_us_rules/resources/DQC_US_0006/dqc_06_date_bounds.csv new file mode 100644 index 0000000000..23dc80a7bb --- /dev/null +++ b/dqc_us_rules/resources/DQC_US_0006/dqc_06_date_bounds.csv @@ -0,0 +1,5 @@ +Period,Min,Max +"FY","340","390" +"Q1","65","115" +"Q3","245","295" +"Q2","155","205" diff --git a/tests/unit_tests/test_dqc_us_0006.py b/tests/unit_tests/test_dqc_us_0006.py index a934fa8d42..e2afcfb297 100644 --- a/tests/unit_tests/test_dqc_us_0006.py +++ b/tests/unit_tests/test_dqc_us_0006.py @@ -2,10 +2,10 @@ # See license.md for license information. # See PatentNotice.md for patent infringement notice. import unittest -import src.dqc_us_0006 as dqc_us_0006 +import dqc_us_rules.dqc_us_0006 as dqc_us_0006 from mock import Mock from collections import defaultdict -import src.util.facts +import dqc_us_rules.util.facts class TestContextDates(unittest.TestCase): @@ -40,10 +40,26 @@ def test_lea_facts_and_update(self): fact1 = Mock(context=context1) fact2 = Mock(context=context2) fact3 = Mock(context=context2) - res1 = src.util.facts.LegalEntityAxis_facts_by_member([fact1, fact2]) - res2 = src.util.facts.LegalEntityAxis_facts_by_member([fact3]) + res1 = dqc_us_rules.util.facts.LegalEntityAxis_facts_by_member([fact1, fact2]) + res2 = dqc_us_rules.util.facts.LegalEntityAxis_facts_by_member([fact3]) res3 = dqc_us_0006._dict_list_update(res1, res2) expected = defaultdict(list) expected.update({'': [fact2, fact3], 'Company1': [fact1]}) self.assertEqual(res3, expected) + +class Test_Date_Bounds_CVS(unittest.TestCase): + def test_date_bounds_cvs_keys(self): + """ + Test to make sure that dictionary read in from the csv shares equals the original DATE_BOUNDS_DICT + """ + DATE_BOUNDS_DICT = { + 'FY':{'min':340,'max':390}, + 'Q1':{'min':65,'max':115}, + 'Q3':{'min':245,'max':295}, + 'Q2':{'min':155,'max':205} + } + + date_bounds_dict_from_csv = dqc_us_0006.date_bounds_from_csv() + + self.assertDictEqual(DATE_BOUNDS_DICT,date_bounds_dict_from_csv) From c840e6cb80f603f36a52701891ead650ca45b7f5 Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Tue, 8 Mar 2016 11:25:02 -0700 Subject: [PATCH 02/16] PR changes made --- dqc_us_rules/dqc_us_0006.py | 13 ++++++++----- dqc_us_rules/util/facts.py | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/dqc_us_rules/dqc_us_0006.py b/dqc_us_rules/dqc_us_0006.py index 4041a8fcd6..5b3bc6f5e6 100644 --- a/dqc_us_rules/dqc_us_0006.py +++ b/dqc_us_rules/dqc_us_0006.py @@ -13,7 +13,10 @@ 'EntityCentralIndexKey', 'EntityFilerCategory'] _CODE_NAME = 'DQC.US.0006' _RULE_VERSION = '1.0' -_DEFAULT_DATE_BOUNDS_FILE = os.path.join(os.path.dirname(__file__), 'resources', 'DQC_US_0006', 'dqc_06_date_bounds.csv') +_DEFAULT_DATE_BOUNDS_FILE = os.path.join(os.path.dirname(__file__), + 'resources', + 'DQC_US_0006', + 'dqc_06_date_bounds.csv') def validate_dates_within_periods(val): @@ -35,7 +38,6 @@ def validate_dates_within_periods(val): ruleVersion=_RULE_VERSION) - def _date_range_check(check_types, check_dei, date_bounds_dict, modelXbrl): """ Takes two lists of fact names, a dict of date boundaries and modelXbrl and then compiles a list of all @@ -43,7 +45,6 @@ def _date_range_check(check_types, check_dei, date_bounds_dict, modelXbrl): date span to the date boundaries for the corresponding document period focus. Any facts with spans less than or larger than the supplied boundaries are returned in a dict based on the document period focus. """ - print("date range check") facts_in_error = defaultdict(list) list_of_facts = facts.LegalEntityAxis_facts_by_member(facts.get_facts_with_type(check_types, modelXbrl)) list_of_facts = _dict_list_update(list_of_facts, (facts.LegalEntityAxis_facts_by_member(facts.get_facts_dei(check_dei, modelXbrl)))) @@ -75,12 +76,14 @@ def _dict_list_update(dict_a, dict_b): dict_a[key].extend(val) return dict_a -def date_bounds_from_csv(): + +def _date_bounds_from_csv(): """ Returns a map of {time_period: {'min':min_value,'max':max_value}} ex: date_bounds_from_csv()['Q1'] = {'min':65,'max':115} - :returns: A map of {time_period: {'min':min_value,'max':max_value}}. + :rtype: dict + :return: A map of {time_period: {'min':min_value,'max':max_value}}. """ with open(_DEFAULT_DATE_BOUNDS_FILE, 'r') as f: reader = csv.reader(f) diff --git a/dqc_us_rules/util/facts.py b/dqc_us_rules/util/facts.py index 7b8c9e0a77..405f599ecc 100644 --- a/dqc_us_rules/util/facts.py +++ b/dqc_us_rules/util/facts.py @@ -185,13 +185,13 @@ def LegalEntityAxis_facts_by_member(facts): return results -def fact_components_valid(fact): +def _fact_components_valid(fact): """ Return true if all of the components in a fact are none :param fact: The fact to check if it is valid :type fact: arelle.ModelInstanceObject.ModelFact - :return: True if none of the components of the fact are None + :return: True if none of the components of the fact are not None :rtype: bool """ if fact is None: From 2f10ed40c937f19fbfd227c0f9ecac20c26dd04e Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Tue, 8 Mar 2016 12:57:19 -0700 Subject: [PATCH 03/16] PR comments satisfied --- tests/unit_tests/test_dqc_us_0006.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/unit_tests/test_dqc_us_0006.py b/tests/unit_tests/test_dqc_us_0006.py index e2afcfb297..3fb48775a6 100644 --- a/tests/unit_tests/test_dqc_us_0006.py +++ b/tests/unit_tests/test_dqc_us_0006.py @@ -49,9 +49,9 @@ def test_lea_facts_and_update(self): self.assertEqual(res3, expected) class Test_Date_Bounds_CVS(unittest.TestCase): - def test_date_bounds_cvs_keys(self): + def test_date_bounds_cvs_keys_equal(self): """ - Test to make sure that dictionary read in from the csv shares equals the original DATE_BOUNDS_DICT + Test to make sure that the dictionary read in from the csv shares equals the original DATE_BOUNDS_DICT """ DATE_BOUNDS_DICT = { 'FY':{'min':340,'max':390}, @@ -63,3 +63,18 @@ def test_date_bounds_cvs_keys(self): date_bounds_dict_from_csv = dqc_us_0006.date_bounds_from_csv() self.assertDictEqual(DATE_BOUNDS_DICT,date_bounds_dict_from_csv) + + def test_date_bounds_cvs_keys_unequal(self): + """ + Test to make sure that the dictionary read is doesn't equal something other than the original DATE_BOUNDS_DICT + """ + RANDOM_DATE_BOUNDS_DICT = { + 'FY':{'min':374, 'max':489}, + 'Q1':{'min':234, 'max':394}, + 'Q3':{'min':890, 'max':891}, + 'Q2':{'min':300, 'max':790} + } + + date_bounds_dict_from_cvs = dqc_us_0006._date_bounds_from_csv() + + self.assertDictUnequal(RANDOM_DATE_BOUNDS_DICT,date_bounds_dict_from_cvs) From 8c9d5987a180c8d889e492c656679913e5266f8f Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Tue, 8 Mar 2016 13:01:20 -0700 Subject: [PATCH 04/16] Read style guide, PR comments satisfied --- dqc_us_rules/dqc_us_0006.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dqc_us_rules/dqc_us_0006.py b/dqc_us_rules/dqc_us_0006.py index 5b3bc6f5e6..2632835c13 100644 --- a/dqc_us_rules/dqc_us_0006.py +++ b/dqc_us_rules/dqc_us_0006.py @@ -13,10 +13,12 @@ 'EntityCentralIndexKey', 'EntityFilerCategory'] _CODE_NAME = 'DQC.US.0006' _RULE_VERSION = '1.0' -_DEFAULT_DATE_BOUNDS_FILE = os.path.join(os.path.dirname(__file__), - 'resources', - 'DQC_US_0006', - 'dqc_06_date_bounds.csv') +_DEFAULT_DATE_BOUNDS_FILE = os.path.join( + os.path.dirname(__file__), + 'resources', + 'DQC_US_0006', + 'dqc_06_date_bounds.csv' +) def validate_dates_within_periods(val): From 12305e81dd2f9f826d76fcc539c627cb44b5752b Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Tue, 8 Mar 2016 13:08:19 -0700 Subject: [PATCH 05/16] Fixed PR comments --- dqc_us_rules/util/facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dqc_us_rules/util/facts.py b/dqc_us_rules/util/facts.py index 405f599ecc..03c6c9343d 100644 --- a/dqc_us_rules/util/facts.py +++ b/dqc_us_rules/util/facts.py @@ -187,7 +187,7 @@ def LegalEntityAxis_facts_by_member(facts): def _fact_components_valid(fact): """ - Return true if all of the components in a fact are none + Return true if all of the components in a fact are not none :param fact: The fact to check if it is valid :type fact: arelle.ModelInstanceObject.ModelFact From c333e95314270710cd18ff27e2f976d90048e4c9 Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Tue, 8 Mar 2016 16:30:48 -0700 Subject: [PATCH 06/16] Corrected changes caused by merge --- dqc_us_rules/dqc_us_0006.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dqc_us_rules/dqc_us_0006.py b/dqc_us_rules/dqc_us_0006.py index 2632835c13..8e25f1bb60 100644 --- a/dqc_us_rules/dqc_us_0006.py +++ b/dqc_us_rules/dqc_us_0006.py @@ -26,7 +26,7 @@ def validate_dates_within_periods(val): Check Date Ranges are within expected values for the fiscal focus period """ - DATE_BOUNDS_DICT = date_bounds_from_csv() + DATE_BOUNDS_DICT = _date_bounds_from_csv() doc_type = facts.lookup_dei_facts('DocumentType', val.modelXbrl) if len(doc_type) != 1 or 'T' in doc_type[0].xValue: # If it is a transitional document, or there is more than one document type declared, we will not run this check. From 3ba085782a419c3fee8205c625ab2f463439e82d Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Tue, 8 Mar 2016 16:39:56 -0700 Subject: [PATCH 07/16] Flake8 fixes of dqc_us_0006 --- dqc_us_rules/dqc_us_0006.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/dqc_us_rules/dqc_us_0006.py b/dqc_us_rules/dqc_us_0006.py index 8e25f1bb60..afe3da6b9f 100644 --- a/dqc_us_rules/dqc_us_0006.py +++ b/dqc_us_rules/dqc_us_0006.py @@ -8,9 +8,12 @@ import os CHECK_TYPES = ['textBlockItemType'] -CHECK_DEI = ['AmendmentDescription', 'AmendmentFlag', 'CurrentFiscalYearEndDate', 'DocumentPeriodEndDate', - 'DocumentFiscalYearFocus', 'DocumentFiscalPeriodFocus', 'DocumentType', 'EntityRegistrantName', - 'EntityCentralIndexKey', 'EntityFilerCategory'] +CHECK_DEI = [ + 'AmendmentDescription', 'AmendmentFlag', 'CurrentFiscalYearEndDate', + 'DocumentPeriodEndDate', 'DocumentFiscalYearFocus', + 'DocumentFiscalPeriodFocus', 'DocumentType', 'EntityRegistrantName', + 'EntityCentralIndexKey', 'EntityFilerCategory' +] _CODE_NAME = 'DQC.US.0006' _RULE_VERSION = '1.0' _DEFAULT_DATE_BOUNDS_FILE = os.path.join( @@ -29,7 +32,8 @@ def validate_dates_within_periods(val): DATE_BOUNDS_DICT = _date_bounds_from_csv() doc_type = facts.lookup_dei_facts('DocumentType', val.modelXbrl) if len(doc_type) != 1 or 'T' in doc_type[0].xValue: - # If it is a transitional document, or there is more than one document type declared, we will not run this check. + # If it is a transitional document, or there is more than one + # document type declared, we will not run this check. return dict_of_facts = _date_range_check(CHECK_TYPES, CHECK_DEI, DATE_BOUNDS_DICT, val.modelXbrl) for document_fiscal_period_focus, fact_list in dict_of_facts.items(): @@ -72,7 +76,8 @@ def _date_range_check(check_types, check_dei, date_bounds_dict, modelXbrl): def _dict_list_update(dict_a, dict_b): """ - helper for the LEA dictionaries, extends the lists from dict_a with the lists in dict_b. + Helper for the LEA dictionaries, extends the lists from dict_a with the + lists in dict_b. """ for key, val in dict_b.items(): dict_a[key].extend(val) @@ -92,13 +97,17 @@ def _date_bounds_from_csv(): date_bounds_dict = {} next(reader, None) for row in reader: - date_bounds_dict[row[0]]={'min':int(row[1]),'max':int(row[2])} + date_bounds_dict[row[0]] = {'min': int(row[1]), 'max': int(row[2])} return date_bounds_dict __pluginInfo__ = { 'name': _CODE_NAME, 'version': _RULE_VERSION, - 'description': '''Checks all of the specified types and concepts for their date ranges to verify the ranges are within expected paramters for the fiscal periods''', - #Mount points + 'description': ( + 'Checks all of the specified types and concepts for their date ' + 'ranges to verify the ranges are within expected paramters for the ' + 'fiscal periods' + ), + # Mount points 'Validate.XBRL.Finally': validate_dates_within_periods, } From faf30736267b8bf91bcc8a4db1e5fcb6c113a3f3 Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Tue, 8 Mar 2016 16:41:40 -0700 Subject: [PATCH 08/16] Fix errors caused in merge --- dqc_us_rules/util/facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dqc_us_rules/util/facts.py b/dqc_us_rules/util/facts.py index 03c6c9343d..7db38167b3 100644 --- a/dqc_us_rules/util/facts.py +++ b/dqc_us_rules/util/facts.py @@ -175,7 +175,7 @@ def LegalEntityAxis_facts_by_member(facts): results = defaultdict(list) for fact in facts: legalDim = LEGALENTITYAXIS_DEFAULT - if fact_components_valid(fact): + if _fact_components_valid(fact): dims = [dim for dim in fact.context.segDimValues.values() if dim.isExplicit and dim.member is not None] for dim in dims: if dim.dimension.qname.localName == 'LegalEntityAxis': From 50b09809ed1373227b40382deab409d15434dd82 Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Tue, 8 Mar 2016 16:43:34 -0700 Subject: [PATCH 09/16] fix errors caused in merge --- tests/unit_tests/test_dqc_us_0006.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/unit_tests/test_dqc_us_0006.py b/tests/unit_tests/test_dqc_us_0006.py index 6dd83dfc4f..ab35382a29 100644 --- a/tests/unit_tests/test_dqc_us_0006.py +++ b/tests/unit_tests/test_dqc_us_0006.py @@ -69,9 +69,9 @@ def test_date_bounds_cvs_keys_equal(self): 'Q2':{'min':155,'max':205} } - date_bounds_dict_from_csv = dqc_us_0006.date_bounds_from_csv() + date_bounds_dict_from_csv = dqc_us_0006._date_bounds_from_csv() - self.assertDictEqual(DATE_BOUNDS_DICT,date_bounds_dict_from_csv) + self.assertDictEqual(DATE_BOUNDS_DICT, date_bounds_dict_from_csv) def test_date_bounds_cvs_keys_unequal(self): """ @@ -85,5 +85,8 @@ def test_date_bounds_cvs_keys_unequal(self): } date_bounds_dict_from_cvs = dqc_us_0006._date_bounds_from_csv() + self.assertEqual(sorted(list(RANDOM_DATE_BOUNDS_DICT.keys())), sorted(list(date_bounds_dict_from_cvs.keys()))) - self.assertDictUnequal(RANDOM_DATE_BOUNDS_DICT,date_bounds_dict_from_cvs) + for key in RANDOM_DATE_BOUNDS_DICT.keys(): + for subkey in RANDOM_DATE_BOUNDS_DICT[key].keys(): + self.assertNotEqual(RANDOM_DATE_BOUNDS_DICT[key][subkey], date_bounds_dict_from_cvs[key][subkey]) From 97a9b450e99e7cbafd353ecbe340d6c7e253395a Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Tue, 8 Mar 2016 16:47:49 -0700 Subject: [PATCH 10/16] Fix flake8 formatting errors --- tests/unit_tests/test_dqc_us_0006.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/unit_tests/test_dqc_us_0006.py b/tests/unit_tests/test_dqc_us_0006.py index ab35382a29..5127394d00 100644 --- a/tests/unit_tests/test_dqc_us_0006.py +++ b/tests/unit_tests/test_dqc_us_0006.py @@ -57,16 +57,18 @@ def test_lea_facts_and_update(self): expected.update({'': [fact2, fact3], 'Company1': [fact1]}) self.assertEqual(res3, expected) -class Test_Date_Bounds_CVS(unittest.TestCase): + +class TestDateBoundsCVS(unittest.TestCase): def test_date_bounds_cvs_keys_equal(self): """ - Test to make sure that the dictionary read in from the csv shares equals the original DATE_BOUNDS_DICT + Test to make sure that the dictionary read in from the csv shares + equals the original DATE_BOUNDS_DICT """ DATE_BOUNDS_DICT = { - 'FY':{'min':340,'max':390}, - 'Q1':{'min':65,'max':115}, - 'Q3':{'min':245,'max':295}, - 'Q2':{'min':155,'max':205} + 'FY': {'min': 340, 'max': 390}, + 'Q1': {'min': 65, 'max': 115}, + 'Q3': {'min': 245, 'max': 295}, + 'Q2': {'min': 155, 'max': 205} } date_bounds_dict_from_csv = dqc_us_0006._date_bounds_from_csv() @@ -75,13 +77,14 @@ def test_date_bounds_cvs_keys_equal(self): def test_date_bounds_cvs_keys_unequal(self): """ - Test to make sure that the dictionary read is doesn't equal something other than the original DATE_BOUNDS_DICT + Test to make sure that the dictionary read is doesn't equal something + other than the original DATE_BOUNDS_DICT """ RANDOM_DATE_BOUNDS_DICT = { - 'FY':{'min':374, 'max':489}, - 'Q1':{'min':234, 'max':394}, - 'Q3':{'min':890, 'max':891}, - 'Q2':{'min':300, 'max':790} + 'FY': {'min': 374, 'max': 489}, + 'Q1': {'min': 234, 'max': 394}, + 'Q3': {'min': 890, 'max': 891}, + 'Q2': {'min': 300, 'max': 790} } date_bounds_dict_from_cvs = dqc_us_0006._date_bounds_from_csv() From f85707740f446cf40a7da021a524ffcb171f22c9 Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Tue, 8 Mar 2016 16:48:34 -0700 Subject: [PATCH 11/16] Fix errors caused in mergs --- tests/unit_tests/util/test_facts.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit_tests/util/test_facts.py b/tests/unit_tests/util/test_facts.py index 872a9683e1..88ba12698d 100644 --- a/tests/unit_tests/util/test_facts.py +++ b/tests/unit_tests/util/test_facts.py @@ -628,14 +628,14 @@ def test_fact_components_valid_on_valid_fact(self): Tests to make sure that a valid fact still works """ fact = Mock(decimals='-4', value='869098', xvalue = 869098, precision = None) - self.assertTrue(fact_lib.fact_components_valid(fact)) + self.assertTrue(fact_lib._fact_components_valid(fact)) def test_fact_components_valid_on_none_type_fact(self): """ Tests to make sure that a None type fact is not valid """ fact = None - self.assertFalse(fact_lib.fact_components_valid(fact)) + self.assertFalse(fact_lib._fact_components_valid(fact)) def test_fact_components_valid_on_none_type_context(self): """ @@ -643,7 +643,7 @@ def test_fact_components_valid_on_none_type_context(self): """ fact = Mock(decimals='-1', value='670', xValue=670, precision=None) fact.context = None - self.assertFalse(fact_lib.fact_components_valid(fact)) + self.assertFalse(fact_lib._fact_components_valid(fact)) def test_fact_components_valid_on_none_type_segDimValue(self): """ @@ -651,4 +651,4 @@ def test_fact_components_valid_on_none_type_segDimValue(self): """ fact = Mock(decimals='-2', value='6500', xValue=6500, precision=None) fact.context.segDimValues = None - self.assertFalse(fact_lib.fact_components_valid(fact)) + self.assertFalse(fact_lib._fact_components_valid(fact)) From 0c66e1f2c39bd5fcd71f1683d0ff6297c6e22e56 Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Tue, 8 Mar 2016 16:51:42 -0700 Subject: [PATCH 12/16] Fix flake8 Errros --- tests/unit_tests/util/test_facts.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/unit_tests/util/test_facts.py b/tests/unit_tests/util/test_facts.py index 88ba12698d..f8a8ccf25a 100644 --- a/tests/unit_tests/util/test_facts.py +++ b/tests/unit_tests/util/test_facts.py @@ -622,12 +622,13 @@ def test_member_qnames(self): expected = ['CashCheckAxis'] self.assertEqual(expected, fact_lib.member_qnames(fact)) + class TestFactsAreValid(unittest.TestCase): def test_fact_components_valid_on_valid_fact(self): """ Tests to make sure that a valid fact still works """ - fact = Mock(decimals='-4', value='869098', xvalue = 869098, precision = None) + fact = Mock(decimals='-4', value='869098', xvalue=869098, precision=None) self.assertTrue(fact_lib._fact_components_valid(fact)) def test_fact_components_valid_on_none_type_fact(self): @@ -647,7 +648,8 @@ def test_fact_components_valid_on_none_type_context(self): def test_fact_components_valid_on_none_type_segDimValue(self): """ - Tests to make sure that a Fact.context with a None type segDimValue is not valid + Tests to make sure that a Fact.context with a None type segDimValue is + not valid """ fact = Mock(decimals='-2', value='6500', xValue=6500, precision=None) fact.context.segDimValues = None From e88c1d2f748b554bffc8012871d618e21e93f574 Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Wed, 9 Mar 2016 00:18:36 -0700 Subject: [PATCH 13/16] Fix spelling and formatting errors --- dqc_us_rules/dqc_us_0006.py | 4 ++-- tests/unit_tests/test_dqc_us_0006.py | 27 +++++++++++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/dqc_us_rules/dqc_us_0006.py b/dqc_us_rules/dqc_us_0006.py index afe3da6b9f..f4ecd94095 100644 --- a/dqc_us_rules/dqc_us_0006.py +++ b/dqc_us_rules/dqc_us_0006.py @@ -29,13 +29,13 @@ def validate_dates_within_periods(val): Check Date Ranges are within expected values for the fiscal focus period """ - DATE_BOUNDS_DICT = _date_bounds_from_csv() + date_bounds_dict = _date_bounds_from_csv() doc_type = facts.lookup_dei_facts('DocumentType', val.modelXbrl) if len(doc_type) != 1 or 'T' in doc_type[0].xValue: # If it is a transitional document, or there is more than one # document type declared, we will not run this check. return - dict_of_facts = _date_range_check(CHECK_TYPES, CHECK_DEI, DATE_BOUNDS_DICT, val.modelXbrl) + dict_of_facts = _date_range_check(CHECK_TYPES, CHECK_DEI, date_bounds_dict, val.modelXbrl) for document_fiscal_period_focus, fact_list in dict_of_facts.items(): for fact in fact_list: val.modelXbrl.error('{}.14'.format(_CODE_NAME), messages.get_message(_CODE_NAME), concept=fact.qname, diff --git a/tests/unit_tests/test_dqc_us_0006.py b/tests/unit_tests/test_dqc_us_0006.py index 5127394d00..b7d0730235 100644 --- a/tests/unit_tests/test_dqc_us_0006.py +++ b/tests/unit_tests/test_dqc_us_0006.py @@ -58,13 +58,13 @@ def test_lea_facts_and_update(self): self.assertEqual(res3, expected) -class TestDateBoundsCVS(unittest.TestCase): - def test_date_bounds_cvs_keys_equal(self): +class TestDateBoundsCSV(unittest.TestCase): + def test_date_bounds_csv_keys_equal(self): """ Test to make sure that the dictionary read in from the csv shares - equals the original DATE_BOUNDS_DICT + equals the original date_bounds_dict """ - DATE_BOUNDS_DICT = { + date_bounds_dict = { 'FY': {'min': 340, 'max': 390}, 'Q1': {'min': 65, 'max': 115}, 'Q3': {'min': 245, 'max': 295}, @@ -73,23 +73,26 @@ def test_date_bounds_cvs_keys_equal(self): date_bounds_dict_from_csv = dqc_us_0006._date_bounds_from_csv() - self.assertDictEqual(DATE_BOUNDS_DICT, date_bounds_dict_from_csv) + self.assertDictEqual(date_bounds_dict, date_bounds_dict_from_csv) - def test_date_bounds_cvs_keys_unequal(self): + def test_date_bounds_csv_keys_unequal(self): """ Test to make sure that the dictionary read is doesn't equal something other than the original DATE_BOUNDS_DICT """ - RANDOM_DATE_BOUNDS_DICT = { + random_date_bounds_dict = { 'FY': {'min': 374, 'max': 489}, 'Q1': {'min': 234, 'max': 394}, 'Q3': {'min': 890, 'max': 891}, 'Q2': {'min': 300, 'max': 790} } - date_bounds_dict_from_cvs = dqc_us_0006._date_bounds_from_csv() - self.assertEqual(sorted(list(RANDOM_DATE_BOUNDS_DICT.keys())), sorted(list(date_bounds_dict_from_cvs.keys()))) + date_bounds_dict_from_csv = dqc_us_0006._date_bounds_from_csv() + self.assertEqual(sorted(list(random_date_bounds_dict.keys())), sorted(list(date_bounds_dict_from_csv.keys()))) - for key in RANDOM_DATE_BOUNDS_DICT.keys(): - for subkey in RANDOM_DATE_BOUNDS_DICT[key].keys(): - self.assertNotEqual(RANDOM_DATE_BOUNDS_DICT[key][subkey], date_bounds_dict_from_cvs[key][subkey]) + for key in random_date_bounds_dict.keys(): + for subkey in random_date_bounds_dict[key].keys(): + self.assertNotEqual( + random_date_bounds_dict[key][subkey], + date_bounds_dict_from_csv[key][subkey] + ) From 02c4eb2e3381afcdd342813ed922e1d614e95f89 Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Mon, 14 Mar 2016 09:40:18 -0600 Subject: [PATCH 14/16] Both fixes in xs-2879 --- dqc_us_rules/util/facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dqc_us_rules/util/facts.py b/dqc_us_rules/util/facts.py index 7b8c9e0a77..d0d5b7390b 100644 --- a/dqc_us_rules/util/facts.py +++ b/dqc_us_rules/util/facts.py @@ -190,7 +190,7 @@ def fact_components_valid(fact): Return true if all of the components in a fact are none :param fact: The fact to check if it is valid - :type fact: arelle.ModelInstanceObject.ModelFact + :type fact: '~arelle.ModelInstanceObject.ModelFact' :return: True if none of the components of the fact are None :rtype: bool """ From ee231760070f454ce36506c6397e7e41b26f9f7b Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Mon, 14 Mar 2016 15:10:24 -0600 Subject: [PATCH 15/16] Fix typo in comment --- dqc_us_rules/util/facts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dqc_us_rules/util/facts.py b/dqc_us_rules/util/facts.py index d0d5b7390b..7f12fffaaf 100644 --- a/dqc_us_rules/util/facts.py +++ b/dqc_us_rules/util/facts.py @@ -187,7 +187,7 @@ def LegalEntityAxis_facts_by_member(facts): def fact_components_valid(fact): """ - Return true if all of the components in a fact are none + Return true if all of the components in a fact are not none :param fact: The fact to check if it is valid :type fact: '~arelle.ModelInstanceObject.ModelFact' From 6e30cf85617b62131d29bb11f0c4203758c70156 Mon Sep 17 00:00:00 2001 From: "Sage.Smith" Date: Mon, 14 Mar 2016 15:55:21 -0600 Subject: [PATCH 16/16] Fix typo in comment --- dqc_us_rules/util/facts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dqc_us_rules/util/facts.py b/dqc_us_rules/util/facts.py index 7f12fffaaf..e0e3c5e775 100644 --- a/dqc_us_rules/util/facts.py +++ b/dqc_us_rules/util/facts.py @@ -187,11 +187,11 @@ def LegalEntityAxis_facts_by_member(facts): def fact_components_valid(fact): """ - Return true if all of the components in a fact are not none + Return true if all of the components in a fact are not None :param fact: The fact to check if it is valid :type fact: '~arelle.ModelInstanceObject.ModelFact' - :return: True if none of the components of the fact are None + :return: True if none of the components of the fact are not None :rtype: bool """ if fact is None: