~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_weave.py

  • Committer: Martin Pool
  • Date: 2005-09-13 08:21:32 UTC
  • Revision ID: mbp@sourcefrog.net-20050913082132-66279763a02e695c
- allow the same version to be repeatedly added to a weave

  (silently absorb them into a single version)

- tests for this

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
 
27
27
import testsweet
28
 
from bzrlib.weave import Weave, WeaveFormatError
 
28
from bzrlib.weave import Weave, WeaveFormatError, WeaveError
29
29
from bzrlib.weavefile import write_weave, read_weave
30
30
from bzrlib.selftest import TestCase
31
31
from pprint import pformat
126
126
                          ['new text!'])
127
127
 
128
128
 
 
129
class RepeatedAdd(TestBase):
 
130
    """Add the same version twice; harmless."""
 
131
    def runTest(self):
 
132
        k = Weave()
 
133
        idx = k.add('text0', [], TEXT_0)
 
134
        idx2 = k.add('text0', [], TEXT_0)
 
135
        self.assertEqual(idx, idx2)
 
136
 
 
137
 
 
138
 
 
139
class InvalidRepeatedAdd(TestBase):
 
140
    def runTest(self):
 
141
        k = Weave()
 
142
        idx = k.add('text0', [], TEXT_0)
 
143
        self.assertRaises(WeaveError,
 
144
                          k.add,
 
145
                          'text0',
 
146
                          [],
 
147
                          ['not the same text'])
 
148
        self.assertRaises(WeaveError,
 
149
                          k.add,
 
150
                          'text0',
 
151
                          [12],         # not the right parents
 
152
                          TEXT_0)
 
153
        
 
154
 
 
155
 
129
156
class InsertLines(TestBase):
130
157
    """Store a revision that adds one line to the original.
131
158