def test_setRenderedValue_personal(self): # Passing a person branch target will set the widget's render state to # 'personal'. self.widget.setUpSubWidgets() target = PersonBranchTarget(self.factory.makePerson()) self.widget.setRenderedValue(target) self.assertEqual('personal', self.widget.default_option)
def setUp(self): TestCaseWithFactory.setUp(self) self.original = self.factory.makePerson() self.target = PersonBranchTarget(self.original)
class TestPersonBranchTarget(TestCaseWithFactory, BaseBranchTargetTests): layer = DatabaseFunctionalLayer def setUp(self): TestCaseWithFactory.setUp(self) self.original = self.factory.makePerson() self.target = PersonBranchTarget(self.original) def makeBranchForTarget(self): return self.factory.makeBranch(owner=self.original, product=None) def test_name(self): # The name of a junk context is '+junk'. self.assertEqual('+junk', self.target.name) def test_getNamespace(self): """Get namespace produces the correct namespace.""" namespace = self.target.getNamespace(self.original) self.assertEqual(namespace.owner, self.original) self.assertRaises(AttributeError, lambda: namespace.product) self.assertRaises(AttributeError, lambda: namespace.sourcepackage) def test_adapter(self): target = IBranchTarget(self.original) self.assertIsInstance(target, PersonBranchTarget) def test_components(self): target = IBranchTarget(self.original) self.assertEqual([self.original], list(target.components)) def test_default_stacked_on_branch(self): # Junk branches are not stacked by default, ever. target = IBranchTarget(self.original) self.assertIs(None, target.default_stacked_on_branch) def test_supports_merge_proposals(self): # Personal branches do not support merge proposals. self.assertFalse(self.target.supports_merge_proposals) def test_supports_short_identites(self): # Personal branches do not support short bzr identites. self.assertFalse(self.target.supports_short_identites) def test_displayname(self): # The display name of a person branch target is ~$USER/+junk. target = IBranchTarget(self.original) self.assertEqual('~%s/+junk' % self.original.name, target.displayname) def test_areBranchesMergeable(self): # No branches are mergeable with a PersonBranchTarget. branch = self.factory.makeAnyBranch() self.assertFalse(self.target.areBranchesMergeable(branch.target)) def test_default_merge_target(self): # The default merge target is always None. self.assertIs(None, self.target.default_merge_target) def test_retargetBranch_packageBranch(self): # Retarget an existing package branch to this target. Override the # mixin tests, and specify the owner of the branch. This is needed to # match the target as the target is the branch owner for a personal # branch. branch = self.factory.makePackageBranch(owner=self.original) self.target._retargetBranch(removeSecurityProxy(branch)) self.assertEqual(self.target, branch.target) def test_retargetBranch_productBranch(self): # Retarget an existing product branch to this target. Override the # mixin tests, and specify the owner of the branch. This is needed to # match the target as the target is the branch owner for a personal # branch. branch = self.factory.makeProductBranch(owner=self.original) self.target._retargetBranch(removeSecurityProxy(branch)) self.assertEqual(self.target, branch.target) def test_retargetBranch_personalBranch(self): # Retarget an existing personal branch to this target. Override the # mixin tests, and specify the owner of the branch. This is needed to # match the target as the target is the branch owner for a personal # branch. branch = self.factory.makePersonalBranch(owner=self.original) self.target._retargetBranch(removeSecurityProxy(branch)) self.assertEqual(self.target, branch.target) def test_doesnt_support_code_imports(self): self.assertFalse(self.target.supports_code_imports) def test_creating_code_import_fails(self): self.assertRaises(AssertionError, self.target.newCodeImport, self.factory.makePerson(), self.factory.getUniqueString("name-"), RevisionControlSystems.GIT, url=self.factory.getUniqueURL())
class TestPersonBranchTarget(TestCaseWithFactory, BaseBranchTargetTests): layer = DatabaseFunctionalLayer def setUp(self): TestCaseWithFactory.setUp(self) self.original = self.factory.makePerson() self.target = PersonBranchTarget(self.original) def makeBranchForTarget(self): return self.factory.makeBranch(owner=self.original, product=None) def test_name(self): # The name of a junk context is '+junk'. self.assertEqual("+junk", self.target.name) def test_getNamespace(self): """Get namespace produces the correct namespace.""" namespace = self.target.getNamespace(self.original) self.assertEqual(namespace.owner, self.original) self.assertRaises(AttributeError, lambda: namespace.product) self.assertRaises(AttributeError, lambda: namespace.sourcepackage) def test_adapter(self): target = IBranchTarget(self.original) self.assertIsInstance(target, PersonBranchTarget) def test_components(self): target = IBranchTarget(self.original) self.assertEqual([self.original], list(target.components)) def test_default_stacked_on_branch(self): # Junk branches are not stacked by default, ever. target = IBranchTarget(self.original) self.assertIs(None, target.default_stacked_on_branch) def test_supports_merge_proposals(self): # Personal branches do not support merge proposals. self.assertFalse(self.target.supports_merge_proposals) def test_supports_short_identites(self): # Personal branches do not support short bzr identites. self.assertFalse(self.target.supports_short_identites) def test_displayname(self): # The display name of a person branch target is ~$USER/+junk. target = IBranchTarget(self.original) self.assertEqual("~%s/+junk" % self.original.name, target.displayname) def test_areBranchesMergeable(self): # No branches are mergeable with a PersonBranchTarget. branch = self.factory.makeAnyBranch() self.assertFalse(self.target.areBranchesMergeable(branch.target)) def test_default_merge_target(self): # The default merge target is always None. self.assertIs(None, self.target.default_merge_target) def test_retargetBranch_packageBranch(self): # Retarget an existing package branch to this target. Override the # mixin tests, and specify the owner of the branch. This is needed to # match the target as the target is the branch owner for a personal # branch. branch = self.factory.makePackageBranch(owner=self.original) self.target._retargetBranch(removeSecurityProxy(branch)) self.assertEqual(self.target, branch.target) def test_retargetBranch_productBranch(self): # Retarget an existing product branch to this target. Override the # mixin tests, and specify the owner of the branch. This is needed to # match the target as the target is the branch owner for a personal # branch. branch = self.factory.makeProductBranch(owner=self.original) self.target._retargetBranch(removeSecurityProxy(branch)) self.assertEqual(self.target, branch.target) def test_retargetBranch_personalBranch(self): # Retarget an existing personal branch to this target. Override the # mixin tests, and specify the owner of the branch. This is needed to # match the target as the target is the branch owner for a personal # branch. branch = self.factory.makePersonalBranch(owner=self.original) self.target._retargetBranch(removeSecurityProxy(branch)) self.assertEqual(self.target, branch.target) def test_doesnt_support_code_imports(self): self.assertFalse(self.target.supports_code_imports) def test_creating_code_import_fails(self): self.assertRaises( AssertionError, self.target.newCodeImport, self.factory.makePerson(), self.factory.getUniqueString("name-"), RevisionControlSystems.GIT, url=self.factory.getUniqueURL(), )