418
418
message = "No such distribution series: 'ningnangnong'."
419
419
self.assertEqual(faults.NotFound(message), fault)
421
def test_createBranch_missing_sourcepackagename(self):
422
# If createBranch is called with the path to a missing source
423
# package, it will create the source package.
424
owner = self.factory.makePerson()
425
distroseries = self.factory.makeDistroSeries()
426
branch_name = self.factory.getUniqueString()
427
unique_name = '/~%s/%s/%s/ningnangnong/%s' % (
428
owner.name, distroseries.distribution.name, distroseries.name,
430
branch_id = self.codehosting_api.createBranch(
431
owner.id, escape(unique_name))
433
branch = self.branch_lookup.get(branch_id)
434
self.assertEqual(owner, branch.owner)
435
self.assertEqual(distroseries, branch.distroseries)
437
'ningnangnong', branch.sourcepackagename.name)
438
self.assertEqual(branch_name, branch.name)
439
self.assertEqual(owner, branch.registrant)
440
self.assertEqual(BranchType.HOSTED, branch.branch_type)
421
442
def test_createBranch_invalid_sourcepackagename(self):
422
# If createBranch is called with the path to an invalid source
423
# package, it will return a Fault saying so.
443
# If createBranch is called with an invalid path, it will fault.
424
444
owner = self.factory.makePerson()
425
445
distroseries = self.factory.makeDistroSeries()
426
446
branch_name = self.factory.getUniqueString()
427
unique_name = '/~%s/%s/%s/ningnangnong/%s' % (
447
unique_name = '/~%s/%s/%s/ningn%%20angnong/%s' % (
428
448
owner.name, distroseries.distribution.name, distroseries.name,
430
450
fault = self.codehosting_api.createBranch(
431
451
owner.id, escape(unique_name))
432
message = "No such source package: 'ningnangnong'."
433
self.assertEqual(faults.NotFound(message), fault)
453
faults.InvalidSourcePackageName('ningn%20angnong'), fault)
435
455
def test_createBranch_using_branch_alias(self):
436
456
# Branches can be created using the branch alias and the full unique