~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_matchers.py

  • Committer: John Arbash Meinel
  • Date: 2011-07-18 14:22:20 UTC
  • mto: This revision was merged to the branch mainline in revision 6033.
  • Revision ID: john@arbash-meinel.com-20110718142220-nwylw659oip1ene9
Start at least testing the package_branch regex.
And start testing the is-up-to-date logic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
from testtools.matchers import *
20
20
 
21
 
from bzrlib.tests import TestCase
 
21
from bzrlib.tests import (
 
22
    TestCase,
 
23
    TestCaseWithTransport,
 
24
    )
22
25
from bzrlib.tests.matchers import *
23
26
 
24
27
 
62
65
        self.assertNotEqual(None, mismatch)
63
66
        self.assertThat(mismatch.describe(), Equals("I am da tree is locked"))
64
67
 
 
68
 
 
69
class TestMatchesAncestry(TestCaseWithTransport):
 
70
 
 
71
    def test__str__(self):
 
72
        matcher = MatchesAncestry("A repository", "arevid")
 
73
        self.assertEqual(
 
74
            "MatchesAncestry(repository='A repository', "
 
75
            "revision_id='arevid')",
 
76
            str(matcher))
 
77
 
 
78
    def test_match(self):
 
79
        b = self.make_branch_builder('.')
 
80
        b.start_series()
 
81
        revid1 = b.build_commit()
 
82
        revid2 = b.build_commit()
 
83
        b.finish_series()
 
84
        branch = b.get_branch()
 
85
        m = MatchesAncestry(branch.repository, revid2)
 
86
        self.assertThat([revid2, revid1], m)
 
87
        self.assertThat([revid1, revid2], m)
 
88
        m = MatchesAncestry(branch.repository, revid1)
 
89
        self.assertThat([revid1], m)
 
90
        m = MatchesAncestry(branch.repository, "unknown")
 
91
        self.assertThat(["unknown"], m)
 
92
 
 
93
    def test_mismatch(self):
 
94
        b = self.make_branch_builder('.')
 
95
        b.start_series()
 
96
        revid1 = b.build_commit()
 
97
        revid2 = b.build_commit()
 
98
        b.finish_series()
 
99
        branch = b.get_branch()
 
100
        m = MatchesAncestry(branch.repository, revid1)
 
101
        mismatch = m.match([])
 
102
        self.assertIsNot(None, mismatch)
 
103
        self.assertEquals(
 
104
            "mismatched ancestry for revision '%s' was ['%s'], expected []" % (
 
105
                revid1, revid1),
 
106
            mismatch.describe())