/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/tests/test_foreign.py

  • Committer: Martin Pool
  • Date: 2009-03-13 07:54:48 UTC
  • mfrom: (4144 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4189.
  • Revision ID: mbp@sourcefrog.net-20090313075448-jlz1t7baz7gzipqn
merge trunk

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
 
50
47
 
51
48
class DummyForeignVcs(foreign.ForeignVcs):
52
49
    """A dummy Foreign VCS, for use with testing.
53
 
    
 
50
 
54
51
    It has revision ids that are a tuple with three strings.
55
52
    """
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
 
65
 
    def test_parse_revision_id_no_dash(self):       
 
66
    def test_parse_revision_id_no_dash(self):
66
67
        reg = foreign.ForeignVcsRegistry()
67
 
        self.assertRaises(errors.InvalidRevisionId, 
 
68
        self.assertRaises(errors.InvalidRevisionId,
68
69
                          reg.parse_revision_id, "invalid")
69
 
        
70
 
    def test_parse_revision_id_unknown_mapping(self):       
 
70
 
 
71
    def test_parse_revision_id_unknown_mapping(self):
71
72
        reg = foreign.ForeignVcsRegistry()
72
 
        self.assertRaises(errors.InvalidRevisionId, 
 
73
        self.assertRaises(errors.InvalidRevisionId,
73
74
                          reg.parse_revision_id, "unknown-foreignrevid")
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()
87
 
        rev = foreign.ForeignRevision(("a", "foreign", "revid"), 
 
88
        mapp = DummyForeignVcsMapping(DummyForeignVcs())
 
89
        rev = foreign.ForeignRevision(("a", "foreign", "revid"),
88
90
                                      mapp, "roundtripped-revid")
89
91
        self.assertEquals("", rev.inventory_sha1)
90
92
        self.assertEquals(("a", "foreign", "revid"), rev.foreign_revid)
96
98
 
97
99
    def setUp(self):
98
100
        super(ShowForeignPropertiesTests, self).setUp()
99
 
        foreign.foreign_vcs_registry.register("dummy", 
100
 
            DummyForeignVcs(), "Dummy VCS")
 
101
        self.vcs = DummyForeignVcs()
 
102
        foreign.foreign_vcs_registry.register("dummy",
 
103
            self.vcs, "Dummy VCS")
101
104
 
102
105
    def tearDown(self):
103
106
        super(ShowForeignPropertiesTests, self).tearDown()
113
116
                          foreign.show_foreign_properties(rev))
114
117
 
115
118
    def test_show_direct(self):
116
 
        rev = foreign.ForeignRevision(("some", "foreign", "revid"), 
117
 
                                      DummyForeignVcsMapping(), 
 
119
        rev = foreign.ForeignRevision(("some", "foreign", "revid"),
 
120
                                      DummyForeignVcsMapping(self.vcs),
118
121
                                      "roundtrip-revid")
119
122
        self.assertEquals({ "dummy ding": "some/foreign\\revid" },
120
123
                          foreign.show_foreign_properties(rev))