Merge ~ubuntu-release/britney/+git/britney2-ubuntu:fix-tests into ~ubuntu-release/britney/+git/britney2-ubuntu:master

Proposed by Iain Lane
Status: Merged
Approved by: Steve Langasek
Approved revision: 177c7a69f7f920b1178b8c2f5b26259fa9df0b8b
Merged at revision: 356d9ceee4bbaedf0fda516697d8ef544a06cebc
Proposed branch: ~ubuntu-release/britney/+git/britney2-ubuntu:fix-tests
Merge into: ~ubuntu-release/britney/+git/britney2-ubuntu:master
Diff against target: 81 lines (+24/-16)
2 files modified
britney2/policies/policy.py (+16/-15)
tests/test_autopkgtest.py (+8/-1)
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Review via email: mp+377694@code.launchpad.net

Description of the change

Fix the testsuite

To post a comment you must log in.
Revision history for this message
Steve Langasek (vorlon) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py
2index a81db75..9cddd33 100644
3--- a/britney2/policies/policy.py
4+++ b/britney2/policies/policy.py
5@@ -2,6 +2,7 @@ import json
6 import os
7 import time
8 from abc import abstractmethod
9+from collections import defaultdict
10 from urllib.parse import quote
11
12 import apt_pkg
13@@ -699,6 +700,7 @@ class LPBlockBugPolicy(BasePolicy):
14
15 return PolicyVerdict.REJECTED_PERMANENTLY
16
17+
18 class LPExcuseBugsPolicy(BasePolicy):
19 """update-excuse Launchpad bug policy to link to a bug report, does not prevent migration
20
21@@ -716,26 +718,25 @@ class LPExcuseBugsPolicy(BasePolicy):
22
23 def initialise(self, britney):
24 super().initialise(britney)
25- self.excuse_bugs = {} # srcpkg -> [(bug, date), ...]
26+ self.excuse_bugs = defaultdict(list) # srcpkg -> [(bug, date), ...]
27
28 filename = os.path.join(self.options.unstable, "ExcuseBugs")
29 self.log("Loading user-supplied excuse bug data from %s" % filename)
30- for line in open(filename):
31- l = line.split()
32- if len(l) != 3:
33- self.log("ExcuseBugs, ignoring malformed line %s" % line, type='W')
34- continue
35- try:
36- self.excuse_bugs.setdefault(l[0], [])
37- self.excuse_bugs[l[0]].append((l[1], int(l[2])))
38- except ValueError:
39- self.log("ExcuseBugs, unable to parse \"%s\"" % line, type='E')
40+ try:
41+ for line in open(filename):
42+ l = line.split()
43+ if len(l) != 3:
44+ self.log("ExcuseBugs, ignoring malformed line %s" % line, type='W')
45+ continue
46+ try:
47+ self.excuse_bugs[l[0]].append((l[1], int(l[2])))
48+ except ValueError:
49+ self.log("ExcuseBugs, unable to parse \"%s\"" % line, type='E')
50+ except FileNotFoundError:
51+ self.log("ExcuseBugs, data file not found, no bugs will be recorded" % filename)
52
53 def apply_policy_impl(self, excuse_bugs_info, suite, source_name, source_data_tdist, source_data_srcdist, excuse):
54- try:
55- excuse_bug = self.excuse_bugs[source_name]
56- except KeyError:
57- return PolicyVerdict.PASS
58+ excuse_bug = self.excuse_bugs[source_name]
59
60 for bug, date in excuse_bug:
61 excuse_bugs_info[bug] = date
62diff --git a/tests/test_autopkgtest.py b/tests/test_autopkgtest.py
63index 3fbba9d..3152270 100755
64--- a/tests/test_autopkgtest.py
65+++ b/tests/test_autopkgtest.py
66@@ -171,7 +171,14 @@ class T(TestBase):
67 try:
68 with open(self.fake_amqp) as f:
69 for line in f:
70- self.amqp_requests.add(line.strip())
71+ # debci-series-amd64:darkgreen {"triggers": ["darkgreen/2"], "submit-time": "2020-01-16 09:47:12"}
72+ # strip the submit time from the requests we're testing; it
73+ # is only for info for people reading the queue
74+ (queuepkg, data) = line.split(' ', 1)
75+ data_json = json.loads(data)
76+ del data_json["submit-time"]
77+ self.amqp_requests.add("{} {}".format(queuepkg,
78+ json.dumps(data_json)))
79 os.unlink(self.fake_amqp)
80 except IOError:
81 pass

Subscribers

People subscribed via source and target branches