def setUp(self):
     """
     Sets up the following test cases
     """
     self.csv_lines = [
         'LIST,ARTIFACT,NEGATION,RELATION,ITEM',
         'BLE,Member,,Contains,Something',
         'BLE,Member,,Contains,PartA,Member,Not,Contains,PartB'
     ]
     self.csv_str = '\n'.join(self.csv_lines)
     # Mock the context managed open statement to return the test CSV
     # mock open specifically in the target module
     open_name = '{0}.open'.format(neg_num.__name__)
     with mock.patch(open_name, create=True) as m:
         m.return_value = io.StringIO(self.csv_str)
         self.blacklist_exclusion_rules = neg_num.get_rules_from_csv(
             dqc_us_0015._DEFAULT_EXCLUSIONS_FILE
         )
     self.rule_one = neg_num._parse_row(
         self.csv_lines[0].split(',')[1:]
     )
     self.rule_two = neg_num._parse_row(
         self.csv_lines[1].split(',')[1:]
     )
     self.rule_three = neg_num._parse_row(
         self.csv_lines[2].split(',')[1:]
     )
 def test_parse_row(self):
     """
     Test _parse_row against expected result
     """
     test_row = [
         'ConceptName', 'Not', 'Contains', 'Reserves', 'ConceptName',
         None, 'Contains', 'Recoveries', 'Period', None, 'Equals',
         'Duration'
     ]
     expected_rule = {
         'artifact': 'ConceptName',
         'item_check': 'Reserves',
         'negation': 'Not',
         'relation': 'Contains',
         'additional_conditions': {
             'artifact': 'ConceptName',
             'item_check': 'Recoveries',
             'negation': None,
             'relation': 'Contains',
             'additional_conditions': {
                 'artifact': 'Period',
                 'item_check': 'Duration',
                 'negation': None,
                 'relation': 'Equals',
                 'additional_conditions': None
             }
         }
     }
     rule = neg_num._parse_row(test_row)
     self.assertDictEqual(rule, expected_rule)
 def test_parse_row(self):
     """
     Test _parse_row against expected result
     """
     test_row = [
         'ConceptName', 'Not', 'Contains', 'Reserves', 'ConceptName', None,
         'Contains', 'Recoveries', 'Period', None, 'Equals', 'Duration'
     ]
     expected_rule = {
         'artifact': 'ConceptName',
         'item_check': 'Reserves',
         'negation': 'Not',
         'relation': 'Contains',
         'additional_conditions': {
             'artifact': 'ConceptName',
             'item_check': 'Recoveries',
             'negation': None,
             'relation': 'Contains',
             'additional_conditions': {
                 'artifact': 'Period',
                 'item_check': 'Duration',
                 'negation': None,
                 'relation': 'Equals',
                 'additional_conditions': None
             }
         }
     }
     rule = neg_num._parse_row(test_row)
     self.assertDictEqual(rule, expected_rule)
 def setUp(self):
     """
     Sets up the following test cases
     """
     self.csv_lines = [
         'LIST,ARTIFACT,NEGATION,RELATION,ITEM',
         'BLE,Member,,Contains,Something',
         'BLE,Member,,Contains,PartA,Member,Not,Contains,PartB'
     ]
     self.csv_str = '\n'.join(self.csv_lines)
     # Mock the context managed open statement to return the test CSV
     # mock open specifically in the target module
     open_name = '{0}.open'.format(neg_num.__name__)
     with mock.patch(open_name, create=True) as m:
         m.return_value = io.StringIO(self.csv_str)
         self.blacklist_exclusion_rules = neg_num.get_rules_from_csv(
             dqc_us_0015._DEFAULT_EXCLUSIONS_FILE)
     self.rule_one = neg_num._parse_row(self.csv_lines[0].split(',')[1:])
     self.rule_two = neg_num._parse_row(self.csv_lines[1].split(',')[1:])
     self.rule_three = neg_num._parse_row(self.csv_lines[2].split(',')[1:])