~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/importd/tests/test_bzrsync.py

  • Committer: david
  • Date: 2005-10-26 22:27:05 UTC
  • mto: (63.2.1) (1102.1.157)
  • mto: This revision was merged to the branch mainline in revision 2836.
  • Revision ID: david@marvin-20051026222705-b1ef3531d795e9a1
schema supports ghost revisions

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 
35
35
    def setUpBzrBranch(self):
36
36
        self.bzr_branch_relpath = "bzr_branch"
37
 
        self.bzr_branch_abspath = self.path(self.bzr_branch_relpath)
 
37
        self.bzr_branch_abspath = self.path(self.bzr_branch_relpath)
38
38
        self.bzr_branch_url = self.url(self.bzr_branch_relpath)
39
39
        os.mkdir(self.bzr_branch_abspath)
40
 
        self.bzr_branch = BzrBranch.initialize(self.bzr_branch_abspath)
 
40
        self.bzr_branch = BzrBranch.initialize(self.bzr_branch_abspath)
41
41
 
42
42
    def setUpDBBranch(self):
43
43
        self.trans_manager.begin()
94
94
                         "Wrong RevisionAuthor count (should be %d, not %d)"
95
95
                         % revisionauthor_pair)
96
96
 
97
 
    def commitRevision(self, *args, **kwargs):
 
97
    def commitRevision(self, message=None, committer=None):
98
98
        file = open(os.path.join(self.bzr_branch_abspath, "file"), "w")
99
99
        file.write(str(time.time()+random.random()))
100
100
        file.close()
101
 
        self.bzr_branch.add("file")
102
 
        if not args and "message" not in kwargs:
103
 
            args = (self.LOG,)
104
 
        if "committer" not in kwargs:
105
 
            kwargs["committer"] = self.AUTHOR
106
 
        self.bzr_branch.commit(*args, **kwargs)
 
101
        inventory = self.bzr_branch.read_working_inventory()
 
102
        if not inventory.has_filename("file"):
 
103
            self.bzr_branch.add("file")
 
104
        if message is None:
 
105
            message = self.LOG
 
106
        if committer is None:
 
107
            committer = self.AUTHOR
 
108
        self.bzr_branch.commit(message, committer=committer)
107
109
 
108
110
    def test_empty_branch(self):
109
111
        """Importing an empty branch does nothing."""
113
115
 
114
116
    def test_import_revision(self):
115
117
        """Importing a revision in history adds one revision and number."""
116
 
        open(os.path.join(self.bzr_branch_abspath, "file"), "w").write("")
117
118
        self.commitRevision()
118
119
        counts = self.getCounts()
119
120
        BzrSync(self.trans_manager, self.db_branch.id).syncHistory()
131
132
        self.assertTrue(db_author)
132
133
        self.assertEquals(db_author.name, author)
133
134
 
 
135
    def test_new_parent(self):
 
136
        """Importing two revisions should import a new parent."""
 
137
        self.commitRevision()
 
138
        self.commitRevision()
 
139
        counts = self.getCounts()
 
140
        BzrSync(self.trans_manager, self.db_branch.id).syncHistory()
 
141
        self.assertCounts(counts, new_revisions=2, new_numbers=2,
 
142
                          new_parents=1)
134
143
 
135
144
TestUtil.register(__name__)
 
145