1
# Copyright (C) 2008-2011 Canonical Ltd
1
# Copyright (C) 2008-2012 Canonical Ltd
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)
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')
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')
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)
508
511
self.do_full_upload()
618
621
self.do_full_upload()
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)
623
627
def test_invalid_revspec(self):
724
728
self.make_branch_and_working_tree()
725
729
self.add_file('hello', 'bar')
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)
748
753
class TestBranchUploadLocations(per_branch.TestCaseWithBranch):
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'))
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" %
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'))
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'))
770
class TestUploadFromRemoteBranch(tests.TestCaseWithTransport,
768
conf = self.get_branch().get_config_stack()
769
conf.set('upload_location', 'foo')
770
self.assertEqual('foo', conf.get('upload_location'))
773
class TestUploadFromRemoteBranch(tests.TestCaseWithTransport, UploadUtilsMixin):
773
775
remote_branch_dir = 'remote_branch'