106
106
def test_rules_filename(self):
107
107
self.assertEqual(rules.rules_filename(),
108
108
self.bzr_home + '/rules')
111
class TestIterSearchRules(tests.TestCaseInTempDir):
113
def make_per_user_searcher(self, lines):
114
"""Make a _RulesSearcher from a list of strings"""
115
return rules._IniBasedRulesSearcher(lines)
117
def make_branch_with_rules(self, text):
118
b = self.make_branch('.')
119
control_files = b.control_files
120
control_files.lock_write()
122
control_files.put_utf8('branch.rules', text)
124
control_files.unlock()
127
def test_iter_search_rules_no_branch(self):
128
per_user = self.make_per_user_searcher([
129
"[./a.txt]", "foo=baz",
130
"[*.txt]", "foo=bar", "a=True"])
131
result = list(rules.iter_search_rules(None, ['a.txt', 'dir/a.txt'],
132
_default_searcher=per_user))
133
self.assertEquals((('foo', 'baz'),), result[0])
134
self.assertEquals((('foo', 'bar'), ('a', 'True')), result[1])
136
def test_iter_search_rules_just_branch(self):
137
per_user = self.make_per_user_searcher([])
138
b = self.make_branch_with_rules(
144
result = list(rules.iter_search_rules(b, ['a.txt', 'dir/a.txt'],
145
_default_searcher=per_user))
146
self.assertEquals((('foo', 'baz'),), result[0])
147
self.assertEquals((('foo', 'bar'), ('a', 'True')), result[1])
149
def test_iter_search_rules_branch_and_per_user(self):
150
per_user = self.make_per_user_searcher([
151
"[./a.txt]", "foo=baz",
152
"[*.txt]", "foo=bar", "a=True"])
153
b = self.make_branch_with_rules(
156
result = list(rules.iter_search_rules(b, ['a.txt', 'dir/a.txt'],
157
_default_searcher=per_user))
158
self.assertEquals((('foo', 'qwerty'),), result[0])
159
self.assertEquals((('foo', 'bar'), ('a', 'True')), result[1])