Merge ~cjwatson/launchpad:avoid-artifactory-deletion into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 8eb9cd94b0fd0fcbbc0e0ce9d47f53589c22b072
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:avoid-artifactory-deletion
Merge into: launchpad:master
Diff against target: 52 lines (+20/-3)
2 files modified
lib/lp/archivepublisher/scripts/publishdistro.py (+4/-1)
lib/lp/archivepublisher/tests/test_publishdistro.py (+16/-2)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+435978@code.launchpad.net

Commit message

Make publisher ignore pending-deletion Artifactory archives

Description of the change

Actually deleting these is unlikely to be at all urgent and can be done manually if needed. Meanwhile, the previous code was causing the publisher to crash with `NotImplementedError: Don't know how to delete archives published using Artifactory`, which caused anything after that point in the publisher's to-do list not to happen.

I also fixed a couple of existing test assertions that I don't believe were quite doing what the test author intended, since they would have passed regardless of whether the archive in question was deleted.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/archivepublisher/scripts/publishdistro.py b/lib/lp/archivepublisher/scripts/publishdistro.py
2index 6c93a6e..3b91fa5 100644
3--- a/lib/lp/archivepublisher/scripts/publishdistro.py
4+++ b/lib/lp/archivepublisher/scripts/publishdistro.py
5@@ -384,7 +384,10 @@ class PublishDistro(PublisherScript):
6
7 def deleteArchive(self, archive, publisher):
8 """Ask `publisher` to delete `archive`."""
9- if archive.purpose == ArchivePurpose.PPA:
10+ if (
11+ archive.purpose == ArchivePurpose.PPA
12+ and archive.publishing_method == ArchivePublishingMethod.LOCAL
13+ ):
14 publisher.deleteArchive()
15 return True
16 else:
17diff --git a/lib/lp/archivepublisher/tests/test_publishdistro.py b/lib/lp/archivepublisher/tests/test_publishdistro.py
18index f99ee6e..fd1d1e6 100644
19--- a/lib/lp/archivepublisher/tests/test_publishdistro.py
20+++ b/lib/lp/archivepublisher/tests/test_publishdistro.py
21@@ -1109,7 +1109,7 @@ class TestPublishDistroMethods(TestCaseWithFactory):
22 ppa, script.getPublisher(distro, ppa, [])
23 )
24 self.assertTrue(deletion_done)
25- self.assertContentEqual([], script.getPPAs(distro))
26+ self.assertEqual(ArchiveStatus.DELETED, ppa.status)
27
28 def test_deleteArchive_ignores_non_ppa(self):
29 # If fed an archive that's not a PPA, deleteArchive will do
30@@ -1121,7 +1121,21 @@ class TestPublishDistroMethods(TestCaseWithFactory):
31 script = self.makeScript(distro)
32 deletion_done = script.deleteArchive(archive, None)
33 self.assertFalse(deletion_done)
34- self.assertEqual(archive, distro.getArchiveByComponent("partner"))
35+ self.assertEqual(ArchiveStatus.ACTIVE, archive.status)
36+
37+ def test_deleteArchive_ignores_non_local(self):
38+ # If fed an Artifactory PPA, deleteArchive will do nothing and
39+ # return False to indicate the fact.
40+ distro = self.makeDistro()
41+ ppa = self.factory.makeArchive(
42+ distro,
43+ purpose=ArchivePurpose.PPA,
44+ publishing_method=ArchivePublishingMethod.ARTIFACTORY,
45+ )
46+ script = self.makeScript(distro)
47+ deletion_done = script.deleteArchive(ppa, None)
48+ self.assertFalse(deletion_done)
49+ self.assertEqual(ArchiveStatus.ACTIVE, ppa.status)
50
51 def test_publishArchive_drives_publisher(self):
52 # publishArchive puts a publisher through its paces. This work

Subscribers

People subscribed via source and target branches

to status/vote changes: