/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/selftest/teststore.py

  • Committer: Robert Collins
  • Date: 2005-09-28 09:35:50 UTC
  • mfrom: (1185.1.47)
  • Revision ID: robertc@robertcollins.net-20050928093550-3ca194dfaffc79f1
merge from integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005 by Canonical Development Ltd
 
2
 
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
 
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
"""Test Store implementation
 
18
"""
 
19
 
 
20
from StringIO import StringIO
 
21
import os
 
22
 
 
23
from bzrlib.remotebranch import RemoteStore
 
24
from bzrlib.store import ImmutableStore, copy_all
 
25
from bzrlib.selftest import TestCaseInTempDir
 
26
from bzrlib.errors import BzrError, UnlistableStore
 
27
 
 
28
 
 
29
class TestStore(TestCaseInTempDir):
 
30
    def test_multiple_add(self):
 
31
        """Multiple add with same ID should raise a BzrError"""
 
32
        store = ImmutableStore('.')
 
33
        store.add(StringIO('goodbye'), '123123')
 
34
        self.assertRaises(BzrError, store.add, StringIO('goodbye'), '123123')
 
35
 
 
36
    def test_copy_all(self):
 
37
        """Test copying"""
 
38
        os.mkdir('a')
 
39
        store_a = ImmutableStore('a')
 
40
        store_a.add('foo', '1')
 
41
        os.mkdir('b')
 
42
        store_b = ImmutableStore('b')
 
43
        copy_all(store_a, store_b)
 
44
        self.assertEqual(store_a['1'].read(), 'foo')
 
45
        self.assertEqual(store_b['1'].read(), 'foo')
 
46
        store_c = RemoteStore('http://example.com/')
 
47
        self.assertRaises(UnlistableStore, copy_all, store_c, store_b)