Merge lp:~stevenk/launchpad/export-security_contact-for-1.0 into lp:launchpad

Proposed by Steve Kowalik on 2012-09-19
Status: Merged
Approved by: Steve Kowalik on 2012-09-19
Approved revision: no longer in the source branch.
Merged at revision: 15983
Proposed branch: lp:~stevenk/launchpad/export-security_contact-for-1.0
Merge into: lp:launchpad
Diff against target: 52 lines (+23/-0)
3 files modified
lib/lp/registry/interfaces/product.py (+6/-0)
lib/lp/registry/model/product.py (+2/-0)
lib/lp/registry/tests/test_product_webservice.py (+15/-0)
To merge this branch: bzr merge lp:~stevenk/launchpad/export-security_contact-for-1.0
Reviewer Review Type Date Requested Status
William Grant code 2012-09-19 Approve on 2012-09-19
Review via email: mp+125092@code.launchpad.net

Commit Message

Export security_contact (as None) on IProduct for 1.0 only.

Description of the Change

During the death of IHasSecurityContact it was removed from every API version. This had the side effect of breaking users scripts. Resurrect security_contact for IProduct for 1.0 only. I did not want to resurrect IHasSecurityContact, so it's still dead on IDistribution.

To post a comment you must log in.
William Grant (wgrant) wrote :

11 + description=_('Obsolete field for security contact')),

This is used in the webservice docs. Perhaps something like "Security contact (obsolete; always None)"?

24 @property
25 + def security_contact(self):
26 + return None

Isn't this just 'security_contact = None'?

51 + self.assertEqual(None, api_prod['security_contact'])

assertIs should be used with None, not assertEqual.

54 + self.assertFalse(api_prod.has_key('security_contact'))

has_key is pretty rare; we usually prefer to use "'key' in dict" instead. If you use that you can probably assertNotIn.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/interfaces/product.py'
2--- lib/lp/registry/interfaces/product.py 2012-09-12 21:08:11 +0000
3+++ lib/lp/registry/interfaces/product.py 2012-09-19 05:18:19 +0000
4@@ -781,6 +781,12 @@
5
6 packagings = Attribute(_("All the packagings for the project."))
7
8+ security_contact = exported(
9+ TextLine(
10+ title=_('Security contact'), required=False, readonly=True,
11+ description=_('Security contact (obsolete; always None)')),
12+ ('devel', dict(exported=False)), as_of='1.0')
13+
14 def checkPrivateBugsTransitionAllowed(private_bugs, user):
15 """Can the private_bugs attribute be changed to the value by the user?
16
17
18=== modified file 'lib/lp/registry/model/product.py'
19--- lib/lp/registry/model/product.py 2012-09-13 16:07:03 +0000
20+++ lib/lp/registry/model/product.py 2012-09-19 05:18:19 +0000
21@@ -408,6 +408,8 @@
22 """
23 pass
24
25+ security_contact = None
26+
27 @property
28 def pillar(self):
29 """See `IBugTarget`."""
30
31=== modified file 'lib/lp/registry/tests/test_product_webservice.py'
32--- lib/lp/registry/tests/test_product_webservice.py 2012-08-29 03:19:38 +0000
33+++ lib/lp/registry/tests/test_product_webservice.py 2012-09-19 05:18:19 +0000
34@@ -103,3 +103,18 @@
35 body=('A current commercial subscription is required to use '
36 'proprietary bugs.')))
37 self.assertIs(None, product.bug_sharing_policy)
38+
39+ def fetch_product(self, webservice, product, api_version):
40+ return webservice.get(
41+ canonical_url(product, force_local_path=True),
42+ api_version=api_version).jsonBody()
43+
44+ def test_security_contact_exported(self):
45+ # security_contact is exported for 1.0, but not for other versions.
46+ product = self.factory.makeProduct()
47+ webservice = webservice_for_person(product.owner)
48+ api_prod = self.fetch_product(webservice, product, '1.0')
49+ self.assertIs(None, api_prod['security_contact'])
50+ for api_version in ('beta', 'devel'):
51+ api_prod = self.fetch_product(webservice, product, api_version)
52+ self.assertNotIn('security_contact', api_prod)