← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/snap-rename-upload-to-push into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/snap-rename-upload-to-push into lp:launchpad.

Commit message:
Use SCA's snap-push endpoint rather than the now-deprecated snap-upload alias.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/snap-rename-upload-to-push/+merge/296099

Use SCA's snap-push endpoint rather than the now-deprecated snap-upload alias.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/snap-rename-upload-to-push into lp:launchpad.
=== modified file 'lib/lp/snappy/model/snapstoreclient.py'
--- lib/lp/snappy/model/snapstoreclient.py	2016-05-30 14:01:39 +0000
+++ lib/lp/snappy/model/snapstoreclient.py	2016-05-31 11:17:04 +0000
@@ -147,7 +147,7 @@
         """Create a new store upload based on the uploaded file."""
         assert config.snappy.store_url is not None
         assert snap.store_name is not None
-        upload_url = urlappend(config.snappy.store_url, "dev/api/snap-upload/")
+        upload_url = urlappend(config.snappy.store_url, "dev/api/snap-push/")
         data = {
             "name": snap.store_name,
             "updown_id": upload_data["upload_id"],

=== modified file 'lib/lp/snappy/tests/test_snapstoreclient.py'
--- lib/lp/snappy/tests/test_snapstoreclient.py	2016-05-30 14:01:39 +0000
+++ lib/lp/snappy/tests/test_snapstoreclient.py	2016-05-31 11:17:04 +0000
@@ -183,9 +183,9 @@
             "content": {"successful": True, "upload_id": 1},
             }
 
-    @urlmatch(path=r".*/snap-upload/$")
-    def _snap_upload_handler(self, url, request):
-        self.snap_upload_request = request
+    @urlmatch(path=r".*/snap-push/$")
+    def _snap_push_handler(self, url, request):
+        self.snap_push_request = request
         return {"status_code": 202, "content": {"success": True}}
 
     @urlmatch(path=r".*/api/v2/tokens/refresh$")
@@ -259,8 +259,7 @@
         lfa = self.factory.makeLibraryFileAlias(content="dummy snap content")
         self.factory.makeSnapFile(snapbuild=snapbuild, libraryfile=lfa)
         transaction.commit()
-        with HTTMock(
-            self._unscanned_upload_handler, self._snap_upload_handler):
+        with HTTMock(self._unscanned_upload_handler, self._snap_push_handler):
             self.client.upload(snapbuild)
         self.assertThat(self.unscanned_upload_request, RequestMatches(
             url=Equals("http://updown.example/unscanned-upload/";),
@@ -271,8 +270,8 @@
                     value="dummy snap content",
                     type="application/octet-stream",
                     )}))
-        self.assertThat(self.snap_upload_request, RequestMatches(
-            url=Equals("http://sca.example/dev/api/snap-upload/";),
+        self.assertThat(self.snap_push_request, RequestMatches(
+            url=Equals("http://sca.example/dev/api/snap-push/";),
             method=Equals("POST"),
             headers=ContainsDict({"Content-Type": Equals("application/json")}),
             auth=("Macaroon", MacaroonsVerify(self.root_key)),
@@ -281,18 +280,18 @@
                 }))
 
     def test_upload_needs_discharge_macaroon_refresh(self):
-        @urlmatch(path=r".*/snap-upload/$")
-        def snap_upload_handler(url, request):
-            snap_upload_handler.call_count += 1
-            if snap_upload_handler.call_count == 1:
-                self.first_snap_upload_request = request
+        @urlmatch(path=r".*/snap-push/$")
+        def snap_push_handler(url, request):
+            snap_push_handler.call_count += 1
+            if snap_push_handler.call_count == 1:
+                self.first_snap_push_request = request
                 return {
                     "status_code": 401,
                     "headers": {
                         "WWW-Authenticate": "Macaroon needs_refresh=1"}}
             else:
-                return self._snap_upload_handler(url, request)
-        snap_upload_handler.call_count = 0
+                return self._snap_push_handler(url, request)
+        snap_push_handler.call_count = 0
 
         store_secrets = self._make_store_secrets()
         snap = self.factory.makeSnap(
@@ -303,10 +302,10 @@
         lfa = self.factory.makeLibraryFileAlias(content="dummy snap content")
         self.factory.makeSnapFile(snapbuild=snapbuild, libraryfile=lfa)
         transaction.commit()
-        with HTTMock(self._unscanned_upload_handler, snap_upload_handler,
+        with HTTMock(self._unscanned_upload_handler, snap_push_handler,
                      self._macaroon_refresh_handler):
             self.client.upload(snapbuild)
-        self.assertEqual(2, snap_upload_handler.call_count)
+        self.assertEqual(2, snap_push_handler.call_count)
         self.assertNotEqual(
             store_secrets["discharge"], snap.store_secrets["discharge"])
 


Follow ups