~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_rules.py

  • Committer: Martin Pool
  • Date: 2011-04-19 07:52:11 UTC
  • mto: This revision was merged to the branch mainline in revision 5833.
  • Revision ID: mbp@sourcefrog.net-20110419075211-3m94qorhr0rg3gzg
Add and test _RulesSearcher.get_single_value

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        rs = self.make_searcher(None)
44
44
        self.assertEquals((), rs.get_items('a.txt'))
45
45
        self.assertEquals((), rs.get_selected_items('a.txt', ['foo']))
 
46
        self.assertEquals(None, rs.get_single_value('a.txt', 'foo'))
46
47
 
47
48
    def test_get_items_file_empty(self):
48
49
        rs = self.make_searcher("")
49
50
        self.assertEquals((), rs.get_items('a.txt'))
50
51
        self.assertEquals((), rs.get_selected_items('a.txt', ['foo']))
 
52
        self.assertEquals(None, rs.get_single_value('a.txt', 'foo'))
51
53
 
52
54
    def test_get_items_from_extension_match(self):
53
55
        rs = self.make_searcher("[name *.txt]\nfoo=bar\na=True\n")
58
60
            rs.get_items('dir/a.txt'))
59
61
        self.assertEquals((('foo', 'bar'),),
60
62
            rs.get_selected_items('a.txt', ['foo']))
 
63
        self.assertEquals('bar', rs.get_single_value('a.txt', 'foo'))
61
64
 
62
65
    def test_get_items_from_multiple_glob_match(self):
63
66
        rs = self.make_searcher(
71
74
            rs.get_items('x x'))
72
75
        self.assertEquals((('foo', 'bar'), ('a', 'True')),
73
76
            rs.get_items('y y'))
 
77
        self.assertEquals('bar', rs.get_single_value('a.txt', 'foo'))
74
78
 
75
79
    def test_get_items_pathname_match(self):
76
80
        rs = self.make_searcher("[name ./a.txt]\nfoo=baz\n")
77
81
        self.assertEquals((('foo', 'baz'),),
78
82
            rs.get_items('a.txt'))
 
83
        self.assertEquals('baz', rs.get_single_value('a.txt', 'foo'))
79
84
        self.assertEquals((), rs.get_items('dir/a.txt'))
 
85
        self.assertEquals(None, rs.get_single_value('dir/a.txt', 'foo'))
80
86
 
81
87
    def test_get_items_match_first(self):
82
88
        rs = self.make_searcher(
84
90
            "[name *.txt]\nfoo=bar\na=True\n")
85
91
        self.assertEquals((('foo', 'baz'),),
86
92
            rs.get_items('a.txt'))
 
93
        self.assertEquals('baz', rs.get_single_value('a.txt', 'foo'))
87
94
        self.assertEquals((('foo', 'bar'), ('a', 'True')),
88
95
            rs.get_items('dir/a.txt'))
 
96
        self.assertEquals('bar', rs.get_single_value('dir/a.txt', 'foo'))
89
97
 
90
98
 
91
99
class TestStackedRulesSearcher(tests.TestCase):
107
115
            "[name *.txt]\nfoo=bar\na=True\n")
108
116
        self.assertEquals((('foo', 'baz'),),
109
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'))
110
120
        self.assertEquals((('foo', 'bar'), ('a', 'True')),
111
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'))
112
124
 
113
125
 
114
126
class TestRulesPath(tests.TestCase):