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
diff --git a/britney2/policies/policy.py b/britney2/policies/policy.py
index a81db75..9cddd33 100644
--- a/britney2/policies/policy.py
+++ b/britney2/policies/policy.py
@@ -2,6 +2,7 @@ import json
2import os2import os
3import time3import time
4from abc import abstractmethod4from abc import abstractmethod
5from collections import defaultdict
5from urllib.parse import quote6from urllib.parse import quote
67
7import apt_pkg8import apt_pkg
@@ -699,6 +700,7 @@ class LPBlockBugPolicy(BasePolicy):
699700
700 return PolicyVerdict.REJECTED_PERMANENTLY701 return PolicyVerdict.REJECTED_PERMANENTLY
701702
703
702class LPExcuseBugsPolicy(BasePolicy):704class LPExcuseBugsPolicy(BasePolicy):
703 """update-excuse Launchpad bug policy to link to a bug report, does not prevent migration705 """update-excuse Launchpad bug policy to link to a bug report, does not prevent migration
704706
@@ -716,26 +718,25 @@ class LPExcuseBugsPolicy(BasePolicy):
716718
717 def initialise(self, britney):719 def initialise(self, britney):
718 super().initialise(britney)720 super().initialise(britney)
719 self.excuse_bugs = {} # srcpkg -> [(bug, date), ...]721 self.excuse_bugs = defaultdict(list) # srcpkg -> [(bug, date), ...]
720722
721 filename = os.path.join(self.options.unstable, "ExcuseBugs")723 filename = os.path.join(self.options.unstable, "ExcuseBugs")
722 self.log("Loading user-supplied excuse bug data from %s" % filename)724 self.log("Loading user-supplied excuse bug data from %s" % filename)
723 for line in open(filename):725 try:
724 l = line.split()726 for line in open(filename):
725 if len(l) != 3:727 l = line.split()
726 self.log("ExcuseBugs, ignoring malformed line %s" % line, type='W')728 if len(l) != 3:
727 continue729 self.log("ExcuseBugs, ignoring malformed line %s" % line, type='W')
728 try:730 continue
729 self.excuse_bugs.setdefault(l[0], [])731 try:
730 self.excuse_bugs[l[0]].append((l[1], int(l[2])))732 self.excuse_bugs[l[0]].append((l[1], int(l[2])))
731 except ValueError:733 except ValueError:
732 self.log("ExcuseBugs, unable to parse \"%s\"" % line, type='E')734 self.log("ExcuseBugs, unable to parse \"%s\"" % line, type='E')
735 except FileNotFoundError:
736 self.log("ExcuseBugs, data file not found, no bugs will be recorded" % filename)
733737
734 def apply_policy_impl(self, excuse_bugs_info, suite, source_name, source_data_tdist, source_data_srcdist, excuse):738 def apply_policy_impl(self, excuse_bugs_info, suite, source_name, source_data_tdist, source_data_srcdist, excuse):
735 try:739 excuse_bug = self.excuse_bugs[source_name]
736 excuse_bug = self.excuse_bugs[source_name]
737 except KeyError:
738 return PolicyVerdict.PASS
739740
740 for bug, date in excuse_bug:741 for bug, date in excuse_bug:
741 excuse_bugs_info[bug] = date742 excuse_bugs_info[bug] = date
diff --git a/tests/test_autopkgtest.py b/tests/test_autopkgtest.py
index 3fbba9d..3152270 100755
--- a/tests/test_autopkgtest.py
+++ b/tests/test_autopkgtest.py
@@ -171,7 +171,14 @@ class T(TestBase):
171 try:171 try:
172 with open(self.fake_amqp) as f:172 with open(self.fake_amqp) as f:
173 for line in f:173 for line in f:
174 self.amqp_requests.add(line.strip())174 # debci-series-amd64:darkgreen {"triggers": ["darkgreen/2"], "submit-time": "2020-01-16 09:47:12"}
175 # strip the submit time from the requests we're testing; it
176 # is only for info for people reading the queue
177 (queuepkg, data) = line.split(' ', 1)
178 data_json = json.loads(data)
179 del data_json["submit-time"]
180 self.amqp_requests.add("{} {}".format(queuepkg,
181 json.dumps(data_json)))
175 os.unlink(self.fake_amqp)182 os.unlink(self.fake_amqp)
176 except IOError:183 except IOError:
177 pass184 pass

Subscribers

People subscribed via source and target branches