~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/teststore.py

  • Committer: John Arbash Meinel
  • Date: 2005-09-29 20:54:18 UTC
  • mto: (1393.1.12)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: john@arbash-meinel.com-20050929205418-009b4b02254baf64
Updated stores to use Transport

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
from bzrlib.transport.local import LocalTransport
24
24
from bzrlib.transport import NoSuchFile
25
25
from bzrlib.store.compressed_text import CompressedTextStore
 
26
from bzrlib.store.text import TextStore
26
27
from bzrlib.selftest import TestCaseInTempDir
27
28
from bzrlib.errors import BzrError, UnlistableStore
28
29
 
95
96
    t = LocalTransport('.')
96
97
    return CompressedTextStore(t)
97
98
 
 
99
def get_text_store():
 
100
    t = LocalTransport('.')
 
101
    return TextStore(t)
 
102
 
98
103
class TestCompressedTextStore(TestCaseInTempDir):
99
104
    def test_multiple_add(self):
100
105
        """Multiple add with same ID should raise a BzrError"""
126
131
        # store_c = RemoteStore('http://example.com/')
127
132
        # self.assertRaises(UnlistableStore, copy_all, store_c, store_b)
128
133
 
 
134
class TestTextStore(TestCaseInTempDir):
 
135
    def test_multiple_add(self):
 
136
        """Multiple add with same ID should raise a BzrError"""
 
137
        store = get_text_store()
 
138
        test_multiple_add(self, store)
 
139
 
 
140
    def test_get(self):
 
141
        store = get_text_store()
 
142
        test_get(self, store)
 
143
 
 
144
    def test_ignore_get(self):
 
145
        store = get_text_store()
 
146
        test_ignore_get(self, store)
 
147
 
 
148
 
 
149
    def test_copy_all(self):
 
150
        """Test copying"""
 
151
        os.mkdir('a')
 
152
        store_a = TextStore('a')
 
153
        store_a.add('foo', '1')
 
154
        os.mkdir('b')
 
155
        store_b = TextStore('b')
 
156
        copy_all(store_a, store_b)
 
157
        self.assertEqual(store_a['1'].read(), 'foo')
 
158
        self.assertEqual(store_b['1'].read(), 'foo')
 
159
        # TODO: Switch the exception form UnlistableStore to
 
160
        #       or make Stores throw UnlistableStore if their
 
161
        #       Transport doesn't support listing
 
162
        # store_c = RemoteStore('http://example.com/')
 
163
        # self.assertRaises(UnlistableStore, copy_all, store_c, store_b)
 
164