← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ilasc/launchpad:bug-1852482 into launchpad:master

 

Ioana Lasc has proposed merging ~ilasc/launchpad:bug-1852482 into launchpad:master.

Commit message:
Created the Unit Test to show generation of the GitRepositoryCreatorNotOwner exception.

Next step is to investigate why on the webservice this exception that is indeed decorated with @error_status(httplib.BAD_REQUEST) surfaces with a 500 http code instead of 400 (which is what we have behind the decorator).

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1852482 in Launchpad itself: "snapcraft remote-build for a non-existent user gives me a 500 error"
  https://bugs.launchpad.net/launchpad/+bug/1852482

For more details, see:
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/375614
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilasc/launchpad:bug-1852482 into launchpad:master.
diff --git a/lib/lp/code/model/tests/test_gitrepository.py b/lib/lp/code/model/tests/test_gitrepository.py
index 145bff4..340c264 100644
--- a/lib/lp/code/model/tests/test_gitrepository.py
+++ b/lib/lp/code/model/tests/test_gitrepository.py
@@ -3036,6 +3036,19 @@ class TestGitRepositorySet(TestCaseWithFactory):
             registrant=owner, owner=owner, target=target, name=name))
         self.assertEqual(0, hosting_fixture.create.call_count)
 
+    def test_new_not_owner(self):
+        # By default, GitRepositorySet.new creates a new repository in the
+        # database but not on the hosting service.
+        hosting_fixture = self.useFixture(GitHostingFixture())
+        owner = self.factory.makePerson()
+        user = self.factory.makePerson()
+        target = self.factory.makeProduct()
+        name = self.factory.getUniqueUnicode()
+
+        self.assertRaises(GitRepositoryCreatorNotOwner,
+                          self.repository_set.new, GitRepositoryType.HOSTED,
+                          user, owner, target, name)
+
     def test_new_with_hosting(self):
         # GitRepositorySet.new(with_hosting=True) creates a new repository
         # in both the database and the hosting service.

Follow ups