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

  • Committer: Ian Clatworthy
  • Date: 2009-02-20 01:45:21 UTC
  • mto: (0.64.124 trunk)
  • mto: This revision was merged to the branch mainline in revision 6631.
  • Revision ID: ian.clatworthy@canonical.com-20090220014521-5mrdgkvd2bvpoi2e
file executable off <-> on tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
159
159
        self.addCleanup(branch.unlock)
160
160
        self.assertEqual(tree.get_symlink_target(file_id), target)
161
161
 
 
162
    def assertExecutable(self, branch, tree, path, executable):
 
163
        file_id = tree.inventory.path2id(path)
 
164
        branch.lock_read()
 
165
        self.addCleanup(branch.unlock)
 
166
        self.assertEqual(tree.is_executable(file_id), executable)
 
167
 
162
168
    def assertRevisionRoot(self, revtree, path):
163
169
        self.assertEqual(revtree.get_revision_id(),
164
170
                         revtree.inventory.root.children[path].revision)
167
173
class TestModify(TestCaseForGenericProcessor):
168
174
 
169
175
    def file_command_iter(self, path, kind='file', content='aaa',
170
 
        to_kind=None, to_content='bbb'):
 
176
        executable=False, to_kind=None, to_content='bbb', to_executable=None):
 
177
        # Revno 1: create a file or symlink
 
178
        # Revno 2: modify it
171
179
        if to_kind is None:
172
180
            to_kind = kind
 
181
        if to_executable is None:
 
182
            to_executable = executable
173
183
        def command_list():
174
184
            author = ['', 'bugs@a.com', time.time(), time.timezone]
175
185
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
176
186
            def files_one():
177
 
                yield commands.FileModifyCommand(path, kind, False,
 
187
                yield commands.FileModifyCommand(path, kind, executable,
178
188
                        None, content)
179
189
            yield commands.CommitCommand('head', '1', author,
180
190
                committer, "commit 1", None, [], files_one)
181
191
            def files_two():
182
 
                yield commands.FileModifyCommand(path, to_kind, False,
 
192
                yield commands.FileModifyCommand(path, to_kind, to_executable,
183
193
                        None, to_content)
184
194
            yield commands.CommitCommand('head', '2', author,
185
195
                committer, "commit 2", ":1", [], files_two)
255
265
        self.assertSymlinkTarget(branch, revtree1, path, "aaa")
256
266
        self.assertContent(branch, revtree2, path, "bbb")
257
267
 
 
268
    def test_modify_file_now_executable(self):
 
269
        handler, branch = self.get_handler()
 
270
        path = 'a/a'
 
271
        handler.process(self.file_command_iter(path,
 
272
            executable=False, to_executable=True, to_content='aaa'))
 
273
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
274
            expected_added=[('a',), (path,)])
 
275
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
276
            expected_modified=[(path,)])
 
277
        self.assertExecutable(branch, revtree1, path, False)
 
278
        self.assertExecutable(branch, revtree2, path, True)
 
279
 
 
280
    def test_modify_file_no_longer_executable(self):
 
281
        handler, branch = self.get_handler()
 
282
        path = 'a/a'
 
283
        handler.process(self.file_command_iter(path,
 
284
            executable=True, to_executable=False, to_content='aaa'))
 
285
        revtree0, revtree1 = self.assertChanges(branch, 1,
 
286
            expected_added=[('a',), (path,)])
 
287
        revtree1, revtree2 = self.assertChanges(branch, 2,
 
288
            expected_modified=[(path,)])
 
289
        self.assertExecutable(branch, revtree1, path, True)
 
290
        self.assertExecutable(branch, revtree2, path, False)
 
291
 
258
292
 
259
293
class TestDelete(TestCaseForGenericProcessor):
260
294
 
261
295
    def file_command_iter(self, path, kind='file'):
 
296
        # Revno 1: create a file or symlink
 
297
        # Revno 2: delete it
262
298
        def command_list():
263
299
            author = ['', 'bugs@a.com', time.time(), time.timezone]
264
300
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
317
353
class TestRename(TestCaseForGenericProcessor):
318
354
 
319
355
    def get_command_iter(self, old_path, new_path):
 
356
        # Revno 1: create a file or symlink
 
357
        # Revno 2: rename it
320
358
        def command_list():
321
359
            author = ['', 'bugs@a.com', time.time(), time.timezone]
322
360
            committer = ['', 'elmer@a.com', time.time(), time.timezone]
360
398
class TestCopy(TestCaseForGenericProcessor):
361
399
 
362
400
    def file_command_iter(self, src_path, dest_path, kind='file'):
 
401
        # Revno 1: create a file or symlink
 
402
        # Revno 2: copy it
363
403
        def command_list():
364
404
            author = ['', 'bugs@a.com', time.time(), time.timezone]
365
405
            committer = ['', 'elmer@a.com', time.time(), time.timezone]