← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:export-move-package into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:export-move-package into launchpad:master.

Commit message:
Declare "move" parameter to Archive.copyPackage

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1329052 in Launchpad itself: "Atomic "move package" operation"
  https://bugs.launchpad.net/launchpad/+bug/1329052

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/389259
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:export-move-package into launchpad:master.
diff --git a/lib/lp/soyuz/browser/tests/test_archive_webservice.py b/lib/lp/soyuz/browser/tests/test_archive_webservice.py
index b9ad921..1ce3759 100644
--- a/lib/lp/soyuz/browser/tests/test_archive_webservice.py
+++ b/lib/lp/soyuz/browser/tests/test_archive_webservice.py
@@ -627,6 +627,32 @@ class TestCopyPackage(TestCaseWithFactory):
         job_source = getUtility(IPlainPackageCopyJobSource)
         copy_job = job_source.getActiveJobs(target_archive).one()
         self.assertEqual(target_archive, copy_job.target_archive)
+        self.assertFalse(copy_job.move)
+
+    def test_copyPackage_move(self):
+        (source, source_archive, source_name, target_archive, to_pocket,
+         to_series, uploader, _, version) = self.setup_data()
+        with person_logged_in(source_archive.owner):
+            source_archive.newComponentUploader(uploader, "main")
+
+        target_archive_url = api_url(target_archive)
+        source_archive_url = api_url(source_archive)
+        ws = webservice_for_person(
+            uploader, permission=OAuthPermission.WRITE_PUBLIC,
+            default_api_version="devel")
+
+        response = ws.named_post(
+            target_archive_url, "copyPackage",
+            source_name=source_name, version=version,
+            from_archive=source_archive_url, to_pocket=to_pocket.name,
+            to_series=to_series.name, include_binaries=False, move=True)
+        self.assertEqual(200, response.status)
+
+        login(ANONYMOUS)
+        job_source = getUtility(IPlainPackageCopyJobSource)
+        copy_job = job_source.getActiveJobs(target_archive).one()
+        self.assertEqual(target_archive, copy_job.target_archive)
+        self.assertTrue(copy_job.move)
 
     def test_copyPackages(self):
         """Basic smoke test"""
@@ -654,6 +680,7 @@ class TestCopyPackage(TestCaseWithFactory):
         job_source = getUtility(IPlainPackageCopyJobSource)
         copy_job = job_source.getActiveJobs(target_archive).one()
         self.assertEqual(target_archive, copy_job.target_archive)
+        self.assertFalse(copy_job.move)
 
 
 class TestGetPublishedBinaries(TestCaseWithFactory):
diff --git a/lib/lp/soyuz/interfaces/archive.py b/lib/lp/soyuz/interfaces/archive.py
index 2aae255..e3f8462 100644
--- a/lib/lp/soyuz/interfaces/archive.py
+++ b/lib/lp/soyuz/interfaces/archive.py
@@ -1515,6 +1515,12 @@ class IArchiveView(IHasBuildRecords):
                           " should be recommended, or None to publish the"
                           " update for everyone."),
             required=False),
+        move=Bool(
+            title=_("Move"),
+            description=_(
+                "If true, delete the source publication after copying it to "
+                "the destination."),
+            required=False),
         )
     @export_write_operation()
     @operation_for_version('devel')