~jelmer/ubuntu/maverick/bzr/2.2.5

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2009-02-14 00:24:06 UTC
  • mfrom: (1.1.48 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20090214002406-h2zfezq54iylm2w8
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    def __eq__(self, other):
29
29
        return type(self) == type(other)
30
30
 
31
 
    def show_foreign_revid(self, foreign_revid):
32
 
        return { "dummy ding": "%s/%s\\%s" % foreign_revid }
33
 
 
34
31
    def revision_id_bzr_to_foreign(self, bzr_revid):
35
32
        return tuple(bzr_revid[len("dummy-v1:"):].split("-")), self
36
33
 
56
53
 
57
54
    def __init__(self):
58
55
        self.mapping_registry = DummyForeignVcsMappingRegistry()
59
 
        self.mapping_registry.register("v1", DummyForeignVcsMapping(), 
 
56
        self.mapping_registry.register("v1", DummyForeignVcsMapping(self), 
60
57
                                       "Version 1")
61
58
 
 
59
    def show_foreign_revid(self, foreign_revid):
 
60
        return { "dummy ding": "%s/%s\\%s" % foreign_revid }
 
61
 
 
62
 
62
63
 
63
64
class ForeignVcsRegistryTests(TestCase):
64
65
 
74
75
 
75
76
    def test_parse_revision_id(self):
76
77
        reg = foreign.ForeignVcsRegistry()
77
 
        reg.register("dummy", DummyForeignVcs(), "Dummy VCS")
78
 
        self.assertEquals((("some", "foreign", "revid"), DummyForeignVcsMapping()),
 
78
        vcs = DummyForeignVcs()
 
79
        reg.register("dummy", vcs, "Dummy VCS")
 
80
        self.assertEquals((("some", "foreign", "revid"), DummyForeignVcsMapping(vcs)),
79
81
                          reg.parse_revision_id("dummy-v1:some-foreign-revid"))
80
82
 
81
83
 
83
85
    """Tests for the ForeignRevision class."""
84
86
 
85
87
    def test_create(self):
86
 
        mapp = DummyForeignVcsMapping()
 
88
        mapp = DummyForeignVcsMapping(DummyForeignVcs())
87
89
        rev = foreign.ForeignRevision(("a", "foreign", "revid"), 
88
90
                                      mapp, "roundtripped-revid")
89
91
        self.assertEquals("", rev.inventory_sha1)
96
98
 
97
99
    def setUp(self):
98
100
        super(ShowForeignPropertiesTests, self).setUp()
 
101
        self.vcs = DummyForeignVcs()
99
102
        foreign.foreign_vcs_registry.register("dummy", 
100
 
            DummyForeignVcs(), "Dummy VCS")
 
103
            self.vcs, "Dummy VCS")
101
104
 
102
105
    def tearDown(self):
103
106
        super(ShowForeignPropertiesTests, self).tearDown()
114
117
 
115
118
    def test_show_direct(self):
116
119
        rev = foreign.ForeignRevision(("some", "foreign", "revid"), 
117
 
                                      DummyForeignVcsMapping(), 
 
120
                                      DummyForeignVcsMapping(self.vcs), 
118
121
                                      "roundtrip-revid")
119
122
        self.assertEquals({ "dummy ding": "some/foreign\\revid" },
120
123
                          foreign.show_foreign_properties(rev))