~bzr-upload-devs/bzr-upload/trunk

« back to all changes in this revision

Viewing changes to tests/test_upload.py

  • Committer: Vincent Ladeuil
  • Date: 2012-03-15 20:53:45 UTC
  • Revision ID: v.ladeuil+lp@free.fr-20120315205345-6ilssa714tfcrntk
Migrate to config stacks

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2011 Canonical Ltd
 
1
# Copyright (C) 2008-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
451
451
        self.assertUpPathDoesNotExist(new_name)
452
452
 
453
453
    def get_upload_auto(self):
454
 
        return cmds.get_upload_auto(self.tree.branch)
 
454
        # We need a fresh branch to check what has been saved on disk
 
455
        b = bzrdir.BzrDir.open(self.tree.basedir).open_branch()
 
456
        return b.get_config_stack().get('upload_auto')
455
457
 
456
458
    def test_upload_auto(self):
457
459
        """Test that upload --auto sets the upload_auto option"""
502
504
        self.add_file('dir/goodbye', 'baz')
503
505
 
504
506
        revid_path = 'dir/revid-path'
505
 
        cmds.set_upload_revid_location(self.tree.branch, revid_path)
 
507
        self.tree.branch.get_config_stack(
 
508
            ).set('upload_revid_location', revid_path)
506
509
        self.assertUpPathDoesNotExist(revid_path)
507
510
 
508
511
        self.do_full_upload()
617
620
 
618
621
        self.do_full_upload()
619
622
 
620
 
        revid_path = cmds.get_upload_revid_location(self.tree.branch)
 
623
        revid_path = self.tree.branch.get_config_stack(
 
624
            ).get('upload_revid_location')
621
625
        self.assertUpPathExists(revid_path)
622
626
 
623
627
    def test_invalid_revspec(self):
724
728
        self.make_branch_and_working_tree()
725
729
        self.add_file('hello', 'bar')
726
730
 
727
 
        revid_path = cmds.get_upload_revid_location(self.tree.branch)
 
731
        revid_path = self.tree.branch.get_config_stack(
 
732
            ).get('upload_revid_location')
728
733
        self.assertUpPathDoesNotExist(revid_path)
729
734
 
730
735
        self.do_upload()
748
753
class TestBranchUploadLocations(per_branch.TestCaseWithBranch):
749
754
 
750
755
    def test_get_upload_location_unset(self):
751
 
        config = self.get_branch().get_config()
752
 
        self.assertEqual(None, config.get_user_option('upload_location'))
 
756
        conf = self.get_branch().get_config_stack()
 
757
        self.assertEqual(None, conf.get('upload_location'))
753
758
 
754
759
    def test_get_push_location_exact(self):
755
760
        config.ensure_config_dir_exists()
756
761
        fn = config.locations_config_filename()
757
762
        b = self.get_branch()
758
 
        open(fn, 'wt').write(("[%s]\n"
759
 
                                  "upload_location=foo\n" %
760
 
                                  b.base.rstrip("/")))
761
 
        conf = b.get_config()
762
 
        self.assertEqual("foo", conf.get_user_option('upload_location'))
 
763
        with open(fn, 'wt') as f:
 
764
            f.write(("[%s]\n" "upload_location=foo\n" % b.base.rstrip("/")))
 
765
        self.assertEqual("foo", b.get_config_stack().get('upload_location'))
763
766
 
764
767
    def test_set_push_location(self):
765
 
        conf = self.get_branch().get_config()
766
 
        conf.set_user_option('upload_location', 'foo')
767
 
        self.assertEqual('foo', conf.get_user_option('upload_location'))
768
 
 
769
 
 
770
 
class TestUploadFromRemoteBranch(tests.TestCaseWithTransport,
771
 
                                 UploadUtilsMixin):
 
768
        conf = self.get_branch().get_config_stack()
 
769
        conf.set('upload_location', 'foo')
 
770
        self.assertEqual('foo', conf.get('upload_location'))
 
771
 
 
772
 
 
773
class TestUploadFromRemoteBranch(tests.TestCaseWithTransport, UploadUtilsMixin):
772
774
 
773
775
    remote_branch_dir = 'remote_branch'
774
776