42
42
def test_get_items_file_missing(self):
43
43
rs = self.make_searcher(None)
44
self.assertEquals((), rs.get_items('a.txt'))
45
self.assertEquals((), rs.get_selected_items('a.txt', ['foo']))
46
self.assertEquals(None, rs.get_single_value('a.txt', 'foo'))
44
self.assertEqual((), rs.get_items('a.txt'))
45
self.assertEqual((), rs.get_selected_items('a.txt', ['foo']))
46
self.assertEqual(None, rs.get_single_value('a.txt', 'foo'))
48
48
def test_get_items_file_empty(self):
49
49
rs = self.make_searcher("")
50
self.assertEquals((), rs.get_items('a.txt'))
51
self.assertEquals((), rs.get_selected_items('a.txt', ['foo']))
52
self.assertEquals(None, rs.get_single_value('a.txt', 'foo'))
50
self.assertEqual((), rs.get_items('a.txt'))
51
self.assertEqual((), rs.get_selected_items('a.txt', ['foo']))
52
self.assertEqual(None, rs.get_single_value('a.txt', 'foo'))
54
54
def test_get_items_from_extension_match(self):
55
55
rs = self.make_searcher("[name *.txt]\nfoo=bar\na=True\n")
56
self.assertEquals((), rs.get_items('a.py'))
57
self.assertEquals((('foo', 'bar'), ('a', 'True')),
56
self.assertEqual((), rs.get_items('a.py'))
57
self.assertEqual((('foo', 'bar'), ('a', 'True')),
58
58
rs.get_items('a.txt'))
59
self.assertEquals((('foo', 'bar'), ('a', 'True')),
59
self.assertEqual((('foo', 'bar'), ('a', 'True')),
60
60
rs.get_items('dir/a.txt'))
61
self.assertEquals((('foo', 'bar'),),
61
self.assertEqual((('foo', 'bar'),),
62
62
rs.get_selected_items('a.txt', ['foo']))
63
self.assertEquals('bar', rs.get_single_value('a.txt', 'foo'))
63
self.assertEqual('bar', rs.get_single_value('a.txt', 'foo'))
65
65
def test_get_items_from_multiple_glob_match(self):
66
66
rs = self.make_searcher(
67
67
"[name *.txt *.py 'x x' \"y y\"]\nfoo=bar\na=True\n")
68
self.assertEquals((), rs.get_items('NEWS'))
69
self.assertEquals((('foo', 'bar'), ('a', 'True')),
68
self.assertEqual((), rs.get_items('NEWS'))
69
self.assertEqual((('foo', 'bar'), ('a', 'True')),
70
70
rs.get_items('a.py'))
71
self.assertEquals((('foo', 'bar'), ('a', 'True')),
71
self.assertEqual((('foo', 'bar'), ('a', 'True')),
72
72
rs.get_items('a.txt'))
73
self.assertEquals((('foo', 'bar'), ('a', 'True')),
73
self.assertEqual((('foo', 'bar'), ('a', 'True')),
74
74
rs.get_items('x x'))
75
self.assertEquals((('foo', 'bar'), ('a', 'True')),
75
self.assertEqual((('foo', 'bar'), ('a', 'True')),
76
76
rs.get_items('y y'))
77
self.assertEquals('bar', rs.get_single_value('a.txt', 'foo'))
77
self.assertEqual('bar', rs.get_single_value('a.txt', 'foo'))
79
79
def test_get_items_pathname_match(self):
80
80
rs = self.make_searcher("[name ./a.txt]\nfoo=baz\n")
81
self.assertEquals((('foo', 'baz'),),
81
self.assertEqual((('foo', 'baz'),),
82
82
rs.get_items('a.txt'))
83
self.assertEquals('baz', rs.get_single_value('a.txt', 'foo'))
84
self.assertEquals((), rs.get_items('dir/a.txt'))
85
self.assertEquals(None, rs.get_single_value('dir/a.txt', 'foo'))
83
self.assertEqual('baz', rs.get_single_value('a.txt', 'foo'))
84
self.assertEqual((), rs.get_items('dir/a.txt'))
85
self.assertEqual(None, rs.get_single_value('dir/a.txt', 'foo'))
87
87
def test_get_items_match_first(self):
88
88
rs = self.make_searcher(
89
89
"[name ./a.txt]\nfoo=baz\n"
90
90
"[name *.txt]\nfoo=bar\na=True\n")
91
self.assertEquals((('foo', 'baz'),),
91
self.assertEqual((('foo', 'baz'),),
92
92
rs.get_items('a.txt'))
93
self.assertEquals('baz', rs.get_single_value('a.txt', 'foo'))
94
self.assertEquals((('foo', 'bar'), ('a', 'True')),
93
self.assertEqual('baz', rs.get_single_value('a.txt', 'foo'))
94
self.assertEqual((('foo', 'bar'), ('a', 'True')),
95
95
rs.get_items('dir/a.txt'))
96
self.assertEquals('bar', rs.get_single_value('dir/a.txt', 'foo'))
96
self.assertEqual('bar', rs.get_single_value('dir/a.txt', 'foo'))
99
99
class TestStackedRulesSearcher(tests.TestCase):
113
113
rs = self.make_searcher(
114
114
"[name ./a.txt]\nfoo=baz\n",
115
115
"[name *.txt]\nfoo=bar\na=True\n")
116
self.assertEquals((('foo', 'baz'),),
116
self.assertEqual((('foo', 'baz'),),
117
117
rs.get_items('a.txt'))
118
self.assertEquals('baz', rs.get_single_value('a.txt', 'foo'))
119
self.assertEquals(None, rs.get_single_value('a.txt', 'a'))
120
self.assertEquals((('foo', 'bar'), ('a', 'True')),
118
self.assertEqual('baz', rs.get_single_value('a.txt', 'foo'))
119
self.assertEqual(None, rs.get_single_value('a.txt', 'a'))
120
self.assertEqual((('foo', 'bar'), ('a', 'True')),
121
121
rs.get_items('dir/a.txt'))
122
self.assertEquals('bar', rs.get_single_value('dir/a.txt', 'foo'))
123
self.assertEquals('True', rs.get_single_value('dir/a.txt', 'a'))
122
self.assertEqual('bar', rs.get_single_value('dir/a.txt', 'foo'))
123
self.assertEqual('True', rs.get_single_value('dir/a.txt', 'a'))
126
126
class TestRulesPath(tests.TestCase):