Example #1
0
 def test_parse_list(self):
     patterns = TagPattern.parse_list('tag+foo,tag-xxx')
     for pattern in patterns:
         self.assertTrue(pattern.match(self.column))
     patterns = TagPattern.parse_list('tag-foo,tag+xxx')
     for pattern in patterns:
         self.assertFalse(pattern.match(self.column))
 def test_parse_list(self):
     patterns = TagPattern.parse_list('tag+foo,tag-xxx')
     for pattern in patterns:
         self.assertTrue(pattern.match(self.column))
     patterns = TagPattern.parse_list('tag-foo,tag+xxx')
     for pattern in patterns:
         self.assertFalse(pattern.match(self.column))
    def test_absolute(self):
        # don't allow exclusions in an absolute pattern
        with self.assertRaises(ValueError):
            pattern = TagPattern.parse('#foo+a-b!')

        pattern = TagPattern.parse('#foo+a!')
        self.assertTrue(pattern.is_absolute)
        self.assertTrue(pattern.match(Column.parse('#foo+a')))
        self.assertFalse(pattern.match(Column.parse('#foo')))
        self.assertFalse(pattern.match(Column.parse('#foo+a+b')))
Example #4
0
    def test_absolute(self):
        # don't allow exclusions in an absolute pattern
        with self.assertRaises(ValueError):
            pattern = TagPattern.parse('#foo+a-b!')

        pattern = TagPattern.parse('#foo+a!')
        self.assertTrue(pattern.is_absolute)
        self.assertTrue(pattern.match(Column.parse('#foo+a')))
        self.assertFalse(pattern.match(Column.parse('#foo')))
        self.assertFalse(pattern.match(Column.parse('#foo+a+b')))
Example #5
0
    def test_parse(self):
        pattern = TagPattern.parse('#tag+foo-xxx')
        self.assertEqual(pattern.tag, '#tag')
        self.assertTrue('foo' in pattern.include_attributes)

        pattern = TagPattern.parse('tag+foo-xxx')
        self.assertEqual(pattern.tag, '#tag')

        pattern = TagPattern.parse('   tag +foo  -xxx  ')
        self.assertEqual(pattern.tag, '#tag')
        self.assertEqual({'foo'}, pattern.include_attributes)
        self.assertEqual({'xxx'}, pattern.exclude_attributes)
    def test_attributes_wildcard(self):
        pattern = TagPattern.parse('*+foo')
        self.assertTrue(pattern.is_wildcard())
        self.assertTrue(pattern.match(self.column))

        pattern = TagPattern.parse('*-foo')
        self.assertTrue(pattern.is_wildcard())
        self.assertFalse(pattern.match(self.column))

        pattern = TagPattern.parse('*+xxx')
        self.assertTrue(pattern.is_wildcard())
        self.assertFalse(pattern.match(self.column))
    def test_parse(self):
        pattern = TagPattern.parse('#tag+foo-xxx')
        self.assertEqual(pattern.tag, '#tag')
        self.assertTrue('foo' in pattern.include_attributes)

        pattern = TagPattern.parse('tag+foo-xxx')
        self.assertEqual(pattern.tag, '#tag')

        pattern = TagPattern.parse('   tag +foo  -xxx  ')
        self.assertEqual(pattern.tag, '#tag')
        self.assertEqual({'foo'}, pattern.include_attributes)
        self.assertEqual({'xxx'}, pattern.exclude_attributes)
Example #8
0
    def test_attributes_wildcard(self):
        pattern = TagPattern.parse('*+foo')
        self.assertTrue(pattern.is_wildcard())
        self.assertTrue(pattern.match(self.column))

        pattern = TagPattern.parse('*-foo')
        self.assertTrue(pattern.is_wildcard())
        self.assertFalse(pattern.match(self.column))

        pattern = TagPattern.parse('*+xxx')
        self.assertTrue(pattern.is_wildcard())
        self.assertFalse(pattern.match(self.column))
 def test_wildcard_empty_column(self):
     pattern = TagPattern.parse('*')
     untagged_column = Column(header="Foo", column_number=1)
     self.assertFalse(pattern.match(untagged_column))
Example #10
0
 def test_simple_wildcard(self):
     pattern = TagPattern.parse('*')
     self.assertTrue(pattern.is_wildcard())
     self.assertTrue(pattern.match(self.column))
Example #11
0
 def test_caseinsensitive(self):
     pattern = TagPattern.parse('#Tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern.parse('#tag+fOO')
     self.assertTrue(pattern.match(self.column))
Example #12
0
 def test_exclude(self):
     pattern = TagPattern('#tag', exclude_attributes=['xxx'])
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tag', exclude_attributes=['foo'])
     self.assertFalse(pattern.match(self.column))
Example #13
0
 def test_simple(self):
     pattern = TagPattern('#tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tagx')
     self.assertFalse(pattern.match(self.column))
Example #14
0
 def test_simple(self):
     pattern = TagPattern('#tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tagx')
     self.assertFalse(pattern.match(self.column))
Example #15
0
 def test_exclude(self):
     pattern = TagPattern('#tag', exclude_attributes=['xxx'])
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tag', exclude_attributes=['foo'])
     self.assertFalse(pattern.match(self.column))
Example #16
0
 def test_caseinsensitive(self):
     pattern = TagPattern.parse('#Tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern.parse('#tag+fOO')
     self.assertTrue(pattern.match(self.column))
Example #17
0
 def test_simple_wildcard(self):
     pattern = TagPattern.parse('*')
     self.assertTrue(pattern.is_wildcard())
     self.assertTrue(pattern.match(self.column))
Example #18
0
 def test_wildcard_empty_column(self):
     pattern = TagPattern.parse('*')
     untagged_column = Column(header="Foo", column_number=1)
     self.assertFalse(pattern.match(untagged_column))
 def test_caseinsensitive(self):
     pattern = TagPattern('#Tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tag', include_attributes=['fOO'])
     self.assertTrue(pattern.match(self.column))
Example #20
0
 def test_caseinsensitive(self):
     pattern = TagPattern('#Tag')
     self.assertTrue(pattern.match(self.column))
     pattern = TagPattern('#tag', include_attributes=['fOO'])
     self.assertTrue(pattern.match(self.column))