def test_column_config_regex_list(self):
     cfg = ColumnConfig(name='List 1', regex=[r'/1/', r'/2/'])
     self.assertEqual(cfg.matchers, [
         RegexMatcherConfig(pattern=r'/1/'),
         RegexMatcherConfig(pattern=r'/2/'),
     ])
     self.assertTrue(cfg.matchers[0].match('1'))
     self.assertFalse(cfg.matchers[0].match('2'))
     self.assertTrue(cfg.matchers[1].match('2'))
    def test_match_header(self):
        header_list = [
            WorkSheetHeaderItem(value="Test", column_index=0),
            WorkSheetHeaderItem(value="Dummy", column_index=1),
            WorkSheetHeaderItem(value="Header 1", column_index=2),
            WorkSheetHeaderItem(value="Header 2", column_index=3),
        ]

        matcher_list = [
            RegexMatcherConfig('/Header 1/i'),
            RegexMatcherConfig('/Header X/i')
        ]

        result = matcher._match_header(header_list, matcher_list)
        self.assertEqual(result, header_list[2])
 def test_column_config_regex_str(self):
     cfg = ColumnConfig(name='List 1', regex=r'/.*/')
     self.assertEqual(cfg.matchers, [RegexMatcherConfig(pattern=r'/.*/')])
     self.assertTrue(cfg.matchers[0].match(' Anything! '))
 def test_column_config_name_only(self):
     cfg = ColumnConfig(name='List 1')
     self.assertEqual(cfg.matchers,
                      [RegexMatcherConfig(pattern=r'/.*List\s+1.*/i')])
     self.assertTrue(cfg.matchers[0].match('   List    1   '))