Merge launchpad:master into launchpad:db-devel

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 5208e7f8f75eb1d093d03c455dcca20a57934b38
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: launchpad:master
Merge into: launchpad:db-devel
Diff against target: 171 lines (+21/-45)
6 files modified
database/sampledata/current-dev.sql (+1/-1)
database/sampledata/current.sql (+1/-1)
lib/lp/registry/model/codeofconduct.py (+1/-1)
lib/lp/registry/tests/test_codeofconduct.py (+18/-0)
lib/lp/scripts/garbo.py (+0/-25)
lib/lp/scripts/tests/test_garbo.py (+0/-17)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+410610@code.launchpad.net

Commit message

Manually merge from master to remove PopulateSignedCodeOfConductAffirmed

Description of the change

This is needed on db-devel to get the latest schema patch to pass its tests. (The garbo job has already run on production, and it's only the test that had a problem, not the job itself.)

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/database/sampledata/current-dev.sql b/database/sampledata/current-dev.sql
2index 7287059..1a40702 100644
3--- a/database/sampledata/current-dev.sql
4+++ b/database/sampledata/current-dev.sql
5@@ -9398,7 +9398,7 @@ ALTER TABLE sharingjob ENABLE TRIGGER ALL;
6
7 ALTER TABLE signedcodeofconduct DISABLE TRIGGER ALL;
8
9-INSERT INTO signedcodeofconduct (id, owner, datecreated, signedcode, recipient, active, admincomment, signing_key_fingerprint) VALUES (1, 16, '2005-09-27 10:01:13', 'Sampledata signedcode', NULL, true, NULL, 'ABCDEF0123456789ABCDDCBA0000111112345678');
10+INSERT INTO signedcodeofconduct (id, owner, datecreated, signedcode, recipient, active, affirmed, admincomment, signing_key_fingerprint) VALUES (1, 16, '2005-09-27 10:01:13', 'Sampledata signedcode', NULL, true, false, NULL, 'ABCDEF0123456789ABCDDCBA0000111112345678');
11
12
13 ALTER TABLE signedcodeofconduct ENABLE TRIGGER ALL;
14diff --git a/database/sampledata/current.sql b/database/sampledata/current.sql
15index dfed6dd..9e0310f 100644
16--- a/database/sampledata/current.sql
17+++ b/database/sampledata/current.sql
18@@ -9312,7 +9312,7 @@ ALTER TABLE sharingjob ENABLE TRIGGER ALL;
19
20 ALTER TABLE signedcodeofconduct DISABLE TRIGGER ALL;
21
22-INSERT INTO signedcodeofconduct (id, owner, datecreated, signedcode, recipient, active, admincomment, signing_key_fingerprint) VALUES (1, 16, '2005-09-27 10:01:13', 'Sampledata signedcode', NULL, true, NULL, 'ABCDEF0123456789ABCDDCBA0000111112345678');
23+INSERT INTO signedcodeofconduct (id, owner, datecreated, signedcode, recipient, active, affirmed, admincomment, signing_key_fingerprint) VALUES (1, 16, '2005-09-27 10:01:13', 'Sampledata signedcode', NULL, true, false, NULL, 'ABCDEF0123456789ABCDDCBA0000111112345678');
24
25
26 ALTER TABLE signedcodeofconduct ENABLE TRIGGER ALL;
27diff --git a/lib/lp/registry/model/codeofconduct.py b/lib/lp/registry/model/codeofconduct.py
28index 2c19f99..65db887 100644
29--- a/lib/lp/registry/model/codeofconduct.py
30+++ b/lib/lp/registry/model/codeofconduct.py
31@@ -199,7 +199,7 @@ class SignedCodeOfConduct(StormBase):
32
33 active = Bool(name='active', allow_none=False, default=False)
34
35- affirmed = Bool(name='affirmed', allow_none=True, default=False,)
36+ affirmed = Bool(name='affirmed', allow_none=False, default=False,)
37
38 version = Unicode(name='version', allow_none=True, default=None)
39
40diff --git a/lib/lp/registry/tests/test_codeofconduct.py b/lib/lp/registry/tests/test_codeofconduct.py
41index 049515c..cc61593 100644
42--- a/lib/lp/registry/tests/test_codeofconduct.py
43+++ b/lib/lp/registry/tests/test_codeofconduct.py
44@@ -5,6 +5,7 @@
45
46 from textwrap import dedent
47
48+from storm.exceptions import NoneError
49 from testtools.matchers import (
50 ContainsDict,
51 Equals,
52@@ -16,6 +17,7 @@ from lp.registry.interfaces.codeofconduct import (
53 ICodeOfConductSet,
54 ISignedCodeOfConductSet,
55 )
56+from lp.registry.model.codeofconduct import SignedCodeOfConduct
57 from lp.services.config import config
58 from lp.services.gpg.handler import PymeSignature
59 from lp.services.gpg.interfaces import (
60@@ -242,3 +244,19 @@ class TestSignedCodeOfConductSet(TestCaseWithFactory):
61 u"You have already affirmed the current Code of Conduct.",
62 getUtility(ISignedCodeOfConductSet).affirmAndStore(
63 user, current.content))
64+
65+
66+class TestSignedCodeOfConduct(TestCaseWithFactory):
67+ layer = ZopelessDatabaseLayer
68+
69+ def test_affirmed_cant_be_instantiated_with_none(self):
70+ self.assertRaises(
71+ NoneError,
72+ SignedCodeOfConduct,
73+ owner=self.factory.makePerson(),
74+ affirmed=None
75+ )
76+
77+ def test_affirmed_cant_be_none(self):
78+ coc = SignedCodeOfConduct(owner=self.factory.makePerson())
79+ self.assertRaises(NoneError, setattr, coc, "affirmed", None)
80diff --git a/lib/lp/scripts/garbo.py b/lib/lp/scripts/garbo.py
81index ce28426..e2471dc 100644
82--- a/lib/lp/scripts/garbo.py
83+++ b/lib/lp/scripts/garbo.py
84@@ -75,7 +75,6 @@ from lp.code.model.revision import (
85 )
86 from lp.oci.model.ocirecipebuild import OCIFile
87 from lp.registry.interfaces.person import IPersonSet
88-from lp.registry.model.codeofconduct import SignedCodeOfConduct
89 from lp.registry.model.person import Person
90 from lp.registry.model.product import Product
91 from lp.registry.model.sourcepackagename import SourcePackageName
92@@ -1765,29 +1764,6 @@ class PopulateSnapBuildStoreRevision(TunableLoop):
93 transaction.commit()
94
95
96-class PopulateSignedCodeOfConductAffirmed(TunableLoop):
97- """Populates SignedCodeOfConduct.affirmed if not set"""
98-
99- maximum_chunk_size = 5000
100-
101- def __init__(self, log, abort_time=None):
102- super().__init__(log, abort_time)
103- self.store = IMasterStore(SignedCodeOfConduct)
104-
105- def findSignedCodeOfConducts(self):
106- return self.store.find(
107- SignedCodeOfConduct,
108- SignedCodeOfConduct.affirmed == None
109- )
110-
111- def isDone(self):
112- return self.findSignedCodeOfConducts().is_empty()
113-
114- def __call__(self, chunk_size):
115- self.findSignedCodeOfConducts()[:chunk_size].set(affirmed=False)
116- transaction.commit()
117-
118-
119 class BaseDatabaseGarbageCollector(LaunchpadCronScript):
120 """Abstract base class to run a collection of TunableLoops."""
121 script_name = None # Script name for locking and database user. Override.
122@@ -2048,7 +2024,6 @@ class HourlyDatabaseGarbageCollector(BaseDatabaseGarbageCollector):
123 GitRepositoryPruner,
124 RevisionCachePruner,
125 UnusedSessionPruner,
126- PopulateSignedCodeOfConductAffirmed,
127 ]
128 experimental_tunable_loops = []
129
130diff --git a/lib/lp/scripts/tests/test_garbo.py b/lib/lp/scripts/tests/test_garbo.py
131index c539bf7..a700663 100644
132--- a/lib/lp/scripts/tests/test_garbo.py
133+++ b/lib/lp/scripts/tests/test_garbo.py
134@@ -84,7 +84,6 @@ from lp.registry.enums import (
135 from lp.registry.interfaces.accesspolicy import IAccessPolicySource
136 from lp.registry.interfaces.person import IPersonSet
137 from lp.registry.interfaces.teammembership import TeamMembershipStatus
138-from lp.registry.model.codeofconduct import SignedCodeOfConduct
139 from lp.registry.model.commercialsubscription import CommercialSubscription
140 from lp.registry.model.teammembership import TeamMembership
141 from lp.scripts.garbo import (
142@@ -97,7 +96,6 @@ from lp.scripts.garbo import (
143 load_garbo_job_state,
144 LoginTokenPruner,
145 OpenIDConsumerAssociationPruner,
146- PopulateSignedCodeOfConductAffirmed,
147 PopulateSnapBuildStoreRevision,
148 ProductVCSPopulator,
149 save_garbo_job_state,
150@@ -2047,21 +2045,6 @@ class TestGarbo(FakeAdapterMixin, TestCaseWithFactory):
151 switch_dbuser('testadmin')
152 self.assertEqual(build1._store_upload_revision, 1)
153
154- def test_PopulateSignedCodeOfConductAffirmed(self):
155- switch_dbuser('testadmin')
156- populator = PopulateSignedCodeOfConductAffirmed(log=None)
157- for _ in range(5):
158- person = self.factory.makePerson()
159- SignedCodeOfConduct(owner=person).affirmed = None
160-
161- result_set = populator.findSignedCodeOfConducts()
162- self.assertGreater(result_set.count(), 0)
163-
164- self.runHourly()
165-
166- result_set = populator.findSignedCodeOfConducts()
167- self.assertTrue(result_set.is_empty())
168-
169
170 class TestGarboTasks(TestCaseWithFactory):
171 layer = LaunchpadZopelessLayer

Subscribers

People subscribed via source and target branches

to status/vote changes: