~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_knit.py

  • Committer: John Arbash Meinel
  • Date: 2006-04-29 15:30:26 UTC
  • mfrom: (1692 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1693.
  • Revision ID: john@arbash-meinel.com-20060429153026-cc7e756ff8a5bf50
[merge] bzr.dev 1692

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
 
23
23
from bzrlib.errors import KnitError, RevisionAlreadyPresent
24
 
from bzrlib.knit import KnitVersionedFile, KnitPlainFactory, KnitAnnotateFactory
 
24
from bzrlib.knit import (
 
25
    KnitVersionedFile,
 
26
    KnitPlainFactory,
 
27
    KnitAnnotateFactory,
 
28
    WeaveToKnit)
25
29
from bzrlib.osutils import split_lines
26
 
from bzrlib.tests import TestCaseInTempDir
 
30
from bzrlib.tests import TestCaseWithTransport
27
31
from bzrlib.transport import TransportLogger
28
32
from bzrlib.transport.local import LocalTransport
29
33
from bzrlib.transport.memory import MemoryTransport
30
 
 
31
 
 
32
 
class KnitTests(TestCaseInTempDir):
33
 
 
34
 
    def add_stock_one_and_one_a(self, k):
35
 
        k.add_lines('text-1', [], split_lines(TEXT_1))
36
 
        k.add_lines('text-1a', ['text-1'], split_lines(TEXT_1A))
37
 
 
38
 
    def test_knit_constructor(self):
39
 
        """Construct empty k"""
40
 
        self.make_test_knit()
 
34
from bzrlib.weave import Weave
 
35
 
 
36
 
 
37
class KnitTests(TestCaseWithTransport):
 
38
    """Class containing knit test helper routines."""
41
39
 
42
40
    def make_test_knit(self, annotate=False):
43
41
        if not annotate:
46
44
            factory = None
47
45
        return KnitVersionedFile('test', LocalTransport('.'), access_mode='w', factory=factory, create=True)
48
46
 
 
47
 
 
48
class BasicKnitTests(KnitTests):
 
49
 
 
50
    def add_stock_one_and_one_a(self, k):
 
51
        k.add_lines('text-1', [], split_lines(TEXT_1))
 
52
        k.add_lines('text-1a', ['text-1'], split_lines(TEXT_1A))
 
53
 
 
54
    def test_knit_constructor(self):
 
55
        """Construct empty k"""
 
56
        self.make_test_knit()
 
57
 
49
58
    def test_knit_add(self):
50
59
        """Store one text in knit and retrieve"""
51
60
        k = self.make_test_knit()
465
474
        i = i + c
466
475
        offset = offset + (b - a) + c
467
476
    return out
 
477
 
 
478
 
 
479
class TestWeaveToKnit(KnitTests):
 
480
 
 
481
    def test_weave_to_knit_matches(self):
 
482
        # check that the WeaveToKnit is_compatible function
 
483
        # registers True for a Weave to a Knit.
 
484
        w = Weave()
 
485
        k = self.make_test_knit()
 
486
        self.failUnless(WeaveToKnit.is_compatible(w, k))
 
487
        self.failIf(WeaveToKnit.is_compatible(k, w))
 
488
        self.failIf(WeaveToKnit.is_compatible(w, w))
 
489
        self.failIf(WeaveToKnit.is_compatible(k, k))