Better debug logging for sourceppa problems.

pre-rebase-2016-12-12
Robert Bruce Park 8 years ago
parent cc50e3a37e
commit 5c74268d75

@ -11,9 +11,11 @@ from policies.policy import BasePolicy, PolicyVerdict
LAUNCHPAD_URL = 'https://api.launchpad.net/1.0/' LAUNCHPAD_URL = 'https://api.launchpad.net/1.0/'
PRIMARY = LAUNCHPAD_URL + 'ubuntu/+archive/primary' PRIMARY = LAUNCHPAD_URL + 'ubuntu/+archive/primary'
IGNORE = [ IGNORE = [
None,
'', '',
'https://api.launchpad.net/1.0/ubuntu/+archive/primary', 'IndexError',
'https://api.launchpad.net/1.0/debian/+archive/primary', LAUNCHPAD_URL + 'ubuntu/+archive/primary',
LAUNCHPAD_URL + 'debian/+archive/primary',
] ]
@ -68,11 +70,12 @@ class SourcePPAPolicy(BasePolicy):
'exact_match': 'true', 'exact_match': 'true',
}) })
try: try:
return data['entries'][0]['copy_source_archive_link'] or '' return data['entries'][0]['copy_source_archive_link']
# IndexError means no packages in -proposed matched this name/version, # IndexError means no packages in -proposed matched this name/version,
# which is expected to happen when bileto runs britney. # which is expected to happen when bileto runs britney.
except IndexError: except IndexError:
return '' self.log('SourcePPA getPackageUploads IndexError (%s %s)' % (pkg, version))
return 'IndexError'
def initialise(self, britney): def initialise(self, britney):
"""Load cached source ppa data""" """Load cached source ppa data"""

@ -63,7 +63,7 @@ class T(unittest.TestCase):
context.getcode.return_value = 200 context.getcode.return_value = 200
context.read.return_value = b'{"entries": []}' context.read.return_value = b'{"entries": []}'
pol = SourcePPAPolicy(FakeOptions) pol = SourcePPAPolicy(FakeOptions)
self.assertEqual(pol.lp_get_source_ppa('hello', '1.0'), '') self.assertEqual(pol.lp_get_source_ppa('hello', '1.0'), 'IndexError')
@patch('policies.sourceppa.urllib.request.urlopen') @patch('policies.sourceppa.urllib.request.urlopen')
def test_lp_rest_api_no_source_ppa(self, urlopen): def test_lp_rest_api_no_source_ppa(self, urlopen):
@ -72,7 +72,7 @@ class T(unittest.TestCase):
context.getcode.return_value = 200 context.getcode.return_value = 200
context.read.return_value = b'{"entries": [{"copy_source_archive_link": null, "other_stuff": "ignored"}]}' context.read.return_value = b'{"entries": [{"copy_source_archive_link": null, "other_stuff": "ignored"}]}'
pol = SourcePPAPolicy(FakeOptions) pol = SourcePPAPolicy(FakeOptions)
self.assertEqual(pol.lp_get_source_ppa('hello', '1.0'), '') self.assertEqual(pol.lp_get_source_ppa('hello', '1.0'), None)
@patch('policies.sourceppa.urllib.request.urlopen') @patch('policies.sourceppa.urllib.request.urlopen')
def test_lp_rest_api_with_source_ppa(self, urlopen): def test_lp_rest_api_with_source_ppa(self, urlopen):

Loading…
Cancel
Save