Ejemplo n.º 1
0
 def test_condition_is_match_mixed_args(self):
     match_key = MatchKey('test %M %M', [], [(is_a, 'var1'), 'var2'])
     result = match_key.is_match('test a b')
     self.assertTrue(result[0])
     self.assertDictEqual(result[1], {'var1':'a', 'var2':'b'})
Ejemplo n.º 2
0
 def test_condition_false_no_match(self):
     match_key = MatchKey('test %M', [], [(is_a, 'var1')])
     result = match_key.is_match('test b')
     self.assertFalse(result[0])
     self.assertDictEqual(result[1], {})
Ejemplo n.º 3
0
 def test_condition_is_match(self):
     match_key = MatchKey('test %M', [], [(is_a, 'var1')])
     result = match_key.is_match('test a')
     self.assertTrue(result[0])
     self.assertDictEqual(result[1], {'var1':'a'})
Ejemplo n.º 4
0
 def test_is_match_wild_no_match_front(self):
     match_key = MatchKey('test %M', [], ['var1'])
     result = match_key.is_match('almost but')
     self.assertFalse(result[0])
     self.assertDictEqual(result[1], {})
Ejemplo n.º 5
0
 def test_is_match_wild_no_match_end(self):
     match_key = MatchKey('test %M nope', [], ['var1'])
     result = match_key.is_match('test yup almost')
     self.assertFalse(result[0])
     self.assertDictEqual(result[1], {})
Ejemplo n.º 6
0
 def test_is_match_partial_back_match(self):
     match_key = MatchKey('test this', [], [])
     result = match_key.is_match('nope this')
     self.assertFalse(result[0])
     self.assertDictEqual(result[1], {})
Ejemplo n.º 7
0
 def test_is_match_wilds_match(self):
     match_key = MatchKey('test %M %M', [], ['var1', 'var2'])
     result = match_key.is_match('test yup this')
     self.assertTrue(result[0])
     self.assertDictEqual(result[1], {'var1':'yup', 'var2':'this'})
Ejemplo n.º 8
0
 def test_condition_is_match_mixed_args(self):
     match_key = MatchKey('test %M %M', [], [(is_a, 'var1'), 'var2'])
     result = match_key.is_match('test a b')
     self.assertTrue(result[0])
     self.assertDictEqual(result[1], {'var1': 'a', 'var2': 'b'})
Ejemplo n.º 9
0
 def test_is_match_all_wrong(self):
     match_key = MatchKey('test this', [], [])
     result = match_key.is_match('nope na')
     self.assertFalse(result[0])
     self.assertDictEqual(result[1], {})
Ejemplo n.º 10
0
 def test_condition_false_no_match(self):
     match_key = MatchKey('test %M', [], [(is_a, 'var1')])
     result = match_key.is_match('test b')
     self.assertFalse(result[0])
     self.assertDictEqual(result[1], {})
Ejemplo n.º 11
0
 def test_condition_is_match(self):
     match_key = MatchKey('test %M', [], [(is_a, 'var1')])
     result = match_key.is_match('test a')
     self.assertTrue(result[0])
     self.assertDictEqual(result[1], {'var1': 'a'})
Ejemplo n.º 12
0
 def test_is_match_wild_no_match_end(self):
     match_key = MatchKey('test %M nope', [], ['var1'])
     result = match_key.is_match('test yup almost')
     self.assertFalse(result[0])
     self.assertDictEqual(result[1], {})
Ejemplo n.º 13
0
 def test_is_match_wild_no_match_front(self):
     match_key = MatchKey('test %M', [], ['var1'])
     result = match_key.is_match('almost but')
     self.assertFalse(result[0])
     self.assertDictEqual(result[1], {})
Ejemplo n.º 14
0
 def test_is_match_wilds_match(self):
     match_key = MatchKey('test %M %M', [], ['var1', 'var2'])
     result = match_key.is_match('test yup this')
     self.assertTrue(result[0])
     self.assertDictEqual(result[1], {'var1': 'yup', 'var2': 'this'})
Ejemplo n.º 15
0
 def test_is_match_partial_back_match(self):
     match_key = MatchKey('test this', [], [])
     result = match_key.is_match('nope this')
     self.assertFalse(result[0])
     self.assertDictEqual(result[1], {})
Ejemplo n.º 16
0
 def test_is_match_all_wrong(self):
     match_key = MatchKey('test this', [], [])
     result = match_key.is_match('nope na')
     self.assertFalse(result[0])
     self.assertDictEqual(result[1], {})