~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_script.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-13 18:11:21 UTC
  • mfrom: (4956.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100113181121-50zma6sk6r0bvq1n
(nmb) Implement mv for shell-like scripts

Show diffs side-by-side

added added

removed removed

Lines of Context:
407
407
$ rm -r dir
408
408
""")
409
409
        self.failIfExists('dir')
 
410
 
 
411
 
 
412
class TestMv(script.TestCaseWithTransportAndScript):
 
413
 
 
414
    def test_usage(self):
 
415
        self.assertRaises(SyntaxError, self.run_script, '$ mv')
 
416
        self.assertRaises(SyntaxError, self.run_script, '$ mv f')
 
417
        self.assertRaises(SyntaxError, self.run_script, '$ mv f1 f2 f3')
 
418
 
 
419
    def test_move_file(self):
 
420
        self.run_script('$ echo content >file')
 
421
        self.failUnlessExists('file')
 
422
        self.run_script('$ mv file new_name')
 
423
        self.failIfExists('file')
 
424
        self.failUnlessExists('new_name')
 
425
 
 
426
    def test_move_unknown_file(self):
 
427
        self.assertRaises(AssertionError,
 
428
                          self.run_script, '$ mv unknown does-not-exist')
 
429
 
 
430
    def test_move_dir(self):
 
431
        self.run_script("""
 
432
$ mkdir dir
 
433
$ echo content >dir/file
 
434
""")
 
435
        self.run_script('$ mv dir new_name')
 
436
        self.failIfExists('dir')
 
437
        self.failUnlessExists('new_name')
 
438
        self.failUnlessExists('new_name/file')
 
439
 
 
440
    def test_move_file_into_dir(self):
 
441
        self.run_script("""
 
442
$ mkdir dir
 
443
$ echo content > file
 
444
""")
 
445
        self.run_script('$ mv file dir')
 
446
        self.failUnlessExists('dir')
 
447
        self.failIfExists('file')
 
448
        self.failUnlessExists('dir/file')
 
449