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(dqc_us_0015.__name__)
     with mock.patch(open_name, create=True) as m:
         m.return_value = io.StringIO(self.csv_str)
         self.blacklist_exclusion_rules = dqc_us_0015.get_rules_from_csv()
     self.rule_one = dqc_us_0015._parse_row(
         self.csv_lines[0].split(',')[1:]
     )
     self.rule_two = dqc_us_0015._parse_row(
         self.csv_lines[1].split(',')[1:]
     )
     self.rule_three = dqc_us_0015._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 = dqc_us_0015._parse_row(test_row)
     self.assertDictEqual(rule, expected_rule)