def setUpClass(cls):
     cls.csv_lines = [
         'LIST,ARTIFACT,NEGATION,RELATION,ITEM',
         'BLE,Member,,Contains,Something',
         'BLE,Member,,Contains,PartA,Member,Not,Contains,PartB'
     ]
     cls.csv_str = '\n'.join(cls.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(cls.csv_str)
         cls.blacklist_exclusion_rules = dqc_us_0015.get_rules_from_csv()
     cls.rule_one = dqc_us_0015._parse_row(cls.csv_lines[0].split(',')[1:])
     cls.rule_two = dqc_us_0015._parse_row(cls.csv_lines[1].split(',')[1:])
     cls.rule_three = dqc_us_0015._parse_row(cls.csv_lines[2].split(',')[1:])
 def setUpClass(cls):
     cls.csv_lines = [
         'LIST,ARTIFACT,NEGATION,RELATION,ITEM',
         'BLE,Member,,Contains,Something',
         'BLE,Member,,Contains,PartA,Member,Not,Contains,PartB'
     ]
     cls.csv_str = '\n'.join(cls.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(cls.csv_str)
         cls.blacklist_exclusion_rules = dqc_us_0015.get_rules_from_csv()
     cls.rule_one = dqc_us_0015._parse_row(cls.csv_lines[0].split(',')[1:])
     cls.rule_two = dqc_us_0015._parse_row(cls.csv_lines[1].split(',')[1:])
     cls.rule_three = dqc_us_0015._parse_row(cls.csv_lines[2].split(',')[1:])
def test_parse_row():
    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)
    assert_dict_equal(rule, expected_rule)
def test_parse_row():
    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)
    assert_dict_equal(rule, expected_rule)