~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_attributes.py

  • Committer: Ian Clatworthy
  • Date: 2008-05-13 06:52:19 UTC
  • mto: (3515.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 3516.
  • Revision ID: ian.clatworthy@canonical.com-20080513065219-uqfkrcr1iooh33je
rename properties to attributes

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
"""Tests for finding and reading the bzr properties file[s]."""
 
17
"""Tests for finding and reading the bzr attributes file[s]."""
18
18
 
19
19
import os
20
20
import sys
21
21
 
22
22
from bzrlib import (
 
23
    attributes,
23
24
    config,
24
 
    properties,
25
25
    tests,
26
26
    )
27
27
from bzrlib.util.configobj import configobj
28
28
 
29
29
 
30
 
class TestPropertiesPath(tests.TestCase):
 
30
class TestAttributesPath(tests.TestCase):
31
31
 
32
32
    def setUp(self):
33
 
        super(TestPropertiesPath, self).setUp()
 
33
        super(TestAttributesPath, self).setUp()
34
34
        os.environ['HOME'] = '/home/bogus'
35
35
        if sys.platform == 'win32':
36
36
            os.environ['BZR_HOME'] = \
40
40
        else:
41
41
            self.bzr_home = '/home/bogus/.bazaar'
42
42
 
43
 
    def test_properties_filename(self):
44
 
        self.assertEqual(properties.properties_filename(),
45
 
                         self.bzr_home + '/fileproperties')
46
 
 
47
 
 
48
 
class TestPropertiesProvider(tests.TestCase):
 
43
    def test_attributes_filename(self):
 
44
        self.assertEqual(attributes.attributes_filename(),
 
45
                         self.bzr_home + '/attributes')
 
46
 
 
47
 
 
48
class TestAttributesProvider(tests.TestCase):
49
49
 
50
50
    def make_provider(self, lines):
51
 
        """Make a _PropertiesProvider from a list of strings"""
 
51
        """Make a _AttributesProvider from a list of strings"""
52
52
        # This works even though the API doesn't document it yet
53
 
        return properties._PropertiesProvider(lines)
 
53
        return attributes._FileBasedAttributesProvider(lines)
54
54
 
55
 
    def test_get_properties_file_missing(self):
 
55
    def test_get_attributes_file_missing(self):
56
56
        pp = self.make_provider(None)
57
 
        self.assertEquals({}, pp.get_properties('a.txt'))
58
 
        self.assertEquals({'foo': None}, pp.get_properties('a.txt', ['foo']))
 
57
        self.assertEquals({}, pp.get_attributes('a.txt'))
 
58
        self.assertEquals({'foo': None}, pp.get_attributes('a.txt', ['foo']))
59
59
 
60
 
    def test_get_properties_file_empty(self):
 
60
    def test_get_attributes_file_empty(self):
61
61
        pp = self.make_provider([])
62
 
        self.assertEquals({}, pp.get_properties('a.txt'))
63
 
        self.assertEquals({'foo': None}, pp.get_properties('a.txt', ['foo']))
 
62
        self.assertEquals({}, pp.get_attributes('a.txt'))
 
63
        self.assertEquals({'foo': None}, pp.get_attributes('a.txt', ['foo']))
64
64
 
65
 
    def test_get_properties_from_extension_match(self):
 
65
    def test_get_attributes_from_extension_match(self):
66
66
        pp = self.make_provider(["[*.txt]", "foo=bar", "a=True"])
67
 
        self.assertEquals({}, pp.get_properties('a.py'))
68
 
        self.assertEquals({'foo':'bar', 'a': 'True'},
69
 
            pp.get_properties('a.txt'))
70
 
        self.assertEquals({'foo':'bar', 'a': 'True'},
71
 
            pp.get_properties('dir/a.txt'))
 
67
        self.assertEquals({}, pp.get_attributes('a.py'))
 
68
        self.assertEquals({'foo':'bar', 'a': 'True'},
 
69
            pp.get_attributes('a.txt'))
 
70
        self.assertEquals({'foo':'bar', 'a': 'True'},
 
71
            pp.get_attributes('dir/a.txt'))
72
72
        self.assertEquals({'foo':'bar'},
73
 
            pp.get_properties('a.txt', ['foo']))
 
73
            pp.get_attributes('a.txt', ['foo']))
74
74
 
75
 
    def test_get_properties_pathname_match(self):
 
75
    def test_get_attributes_pathname_match(self):
76
76
        pp = self.make_provider(["[./a.txt]", "foo=baz"])
77
 
        self.assertEquals({'foo':'baz'}, pp.get_properties('a.txt'))
78
 
        self.assertEquals({}, pp.get_properties('dir/a.txt'))
 
77
        self.assertEquals({'foo':'baz'}, pp.get_attributes('a.txt'))
 
78
        self.assertEquals({}, pp.get_attributes('dir/a.txt'))
79
79
 
80
 
    def test_get_properties_match_first(self):
 
80
    def test_get_attributes_match_first(self):
81
81
        pp = self.make_provider([
82
82
            "[./a.txt]", "foo=baz",
83
83
            "[*.txt]", "foo=bar", "a=True"])
84
 
        self.assertEquals({'foo':'baz'}, pp.get_properties('a.txt'))
 
84
        self.assertEquals({'foo':'baz'}, pp.get_attributes('a.txt'))
85
85
        self.assertEquals({'foo':'bar', 'a': 'True'},
86
 
            pp.get_properties('dir/a.txt'))
 
86
            pp.get_attributes('dir/a.txt'))