Merge ~cjwatson/launchpad:responses-0.17.0 into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: fd9f41b803959fc7d014669f2bcca86ad4c08d64
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:responses-0.17.0
Merge into: launchpad:master
Diff against target: 151 lines (+31/-15)
6 files modified
lib/lp/archivepublisher/tests/artifactory_fixture.py (+0/-1)
lib/lp/bugs/doc/sourceforge-remote-products.rst (+15/-2)
lib/lp/bugs/externalbugtracker/tests/test_gitlab.py (+3/-3)
lib/lp/bugs/tests/test_bugtracker.py (+7/-3)
lib/lp/bugs/tests/test_bzremotecomponentfinder.py (+5/-4)
requirements/launchpad.txt (+1/-2)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+446347@code.launchpad.net

Commit message

Upgrade to responses 0.17.0

Description of the change

This is as far as we can go while retaining Python 3.5 support, but it's enough to fix several warnings in the test suite.

Dependencies MP: https://code.launchpad.net/~cjwatson/lp-source-dependencies/+git/lp-source-dependencies/+merge/446346

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/archivepublisher/tests/artifactory_fixture.py b/lib/lp/archivepublisher/tests/artifactory_fixture.py
2index 52098a3..95f6d75 100644
3--- a/lib/lp/archivepublisher/tests/artifactory_fixture.py
4+++ b/lib/lp/archivepublisher/tests/artifactory_fixture.py
5@@ -46,7 +46,6 @@ class FakeArtifactoryFixture(Fixture):
6 method="GET",
7 url=repo_url_regex,
8 callback=self._handle_download,
9- stream=True,
10 )
11 )
12 self.requests_mock.add_callback(
13diff --git a/lib/lp/bugs/doc/sourceforge-remote-products.rst b/lib/lp/bugs/doc/sourceforge-remote-products.rst
14index 45c09f9..6367fd5 100644
15--- a/lib/lp/bugs/doc/sourceforge-remote-products.rst
16+++ b/lib/lp/bugs/doc/sourceforge-remote-products.rst
17@@ -81,11 +81,24 @@ Define some request mocks so that we don't try to access SourceForge.
18 ... with open(file_path) as test_file:
19 ... return (200, {}, test_file.read())
20 ...
21+ >>> def match_group_id(request):
22+ ... request_query = urlsplit(request.url).query
23+ ... if re.match(r"group_id=[0-9]+.*", request_query) is not None:
24+ ... return True, ""
25+ ... else:
26+ ... return (
27+ ... False,
28+ ... "Query string doesn't match. "
29+ ... "{} doesn't match group_id=[0-9]+.*".format(
30+ ... request_query
31+ ... ),
32+ ... )
33+ ...
34 >>> def add_tracker_response(requests_mock):
35 ... requests_mock.add_callback(
36 ... "GET",
37- ... re.compile(r".*/tracker/\?group_id=[0-9]+"),
38- ... match_querystring=True,
39+ ... re.compile(r".*/tracker/"),
40+ ... match=[match_group_id],
41 ... callback=tracker_callback,
42 ... )
43 ...
44diff --git a/lib/lp/bugs/externalbugtracker/tests/test_gitlab.py b/lib/lp/bugs/externalbugtracker/tests/test_gitlab.py
45index cb53149..f9acca7 100644
46--- a/lib/lp/bugs/externalbugtracker/tests/test_gitlab.py
47+++ b/lib/lp/bugs/externalbugtracker/tests/test_gitlab.py
48@@ -9,6 +9,7 @@ from urllib.parse import parse_qs, urlsplit, urlunsplit
49
50 import responses
51 import transaction
52+from responses.matchers import query_string_matcher
53 from testtools.matchers import (
54 Contains,
55 ContainsDict,
56@@ -300,10 +301,9 @@ class TestGitLabUpdateBugWatches(TestCaseWithFactory):
57 ]
58 responses.add(
59 "GET",
60- "https://gitlab.com/api/v4/projects/user%2Frepository/issues?"
61- "iids%5B%5D=1234",
62+ "https://gitlab.com/api/v4/projects/user%2Frepository/issues",
63 json=remote_bug,
64- match_querystring=True,
65+ match=[query_string_matcher("iids%5B%5D=1234")],
66 )
67 bug = self.factory.makeBug()
68 bug_tracker = self.factory.makeBugTracker(
69diff --git a/lib/lp/bugs/tests/test_bugtracker.py b/lib/lp/bugs/tests/test_bugtracker.py
70index 6bb19ca..bcc3d1a 100644
71--- a/lib/lp/bugs/tests/test_bugtracker.py
72+++ b/lib/lp/bugs/tests/test_bugtracker.py
73@@ -9,6 +9,7 @@ from urllib.parse import urlencode
74 import responses
75 import transaction
76 from lazr.lifecycle.snapshot import Snapshot
77+from responses.matchers import query_string_matcher
78 from storm.store import Store
79 from testtools.matchers import Equals, MatchesListwise, MatchesStructure
80 from zope.component import getUtility
81@@ -288,9 +289,12 @@ class TestMantis(TestCaseWithFactory):
82 )
83 responses.add(
84 "GET",
85- "http://mantis.example.com/login.php?"
86- "username=guest&password=guest&return=%2Fsome%2Fpage",
87- match_querystring=True,
88+ "http://mantis.example.com/login.php",
89+ match=[
90+ query_string_matcher(
91+ "username=guest&password=guest&return=%2Fsome%2Fpage"
92+ )
93+ ],
94 status=200,
95 body="sentinel",
96 )
97diff --git a/lib/lp/bugs/tests/test_bzremotecomponentfinder.py b/lib/lp/bugs/tests/test_bzremotecomponentfinder.py
98index 47480f2..3e2c210 100644
99--- a/lib/lp/bugs/tests/test_bzremotecomponentfinder.py
100+++ b/lib/lp/bugs/tests/test_bzremotecomponentfinder.py
101@@ -8,6 +8,7 @@ from typing import List
102
103 import responses
104 import transaction
105+from responses.matchers import query_string_matcher
106
107 from lp.bugs.scripts.bzremotecomponentfinder import (
108 BugzillaRemoteComponentFinder,
109@@ -168,8 +169,8 @@ class TestBugzillaRemoteComponentFinder(TestCaseWithFactory):
110 finder = BugzillaRemoteComponentFinder(logger=BufferLogger())
111 responses.add(
112 "GET",
113- re.compile(r".*/query\.cgi\?format=advanced"),
114- match_querystring=True,
115+ re.compile(r".*/query\.cgi"),
116+ match=[query_string_matcher("format=advanced")],
117 content_type="text/html",
118 body=read_test_file("bugzilla-fdo-advanced-query.html"),
119 )
120@@ -202,8 +203,8 @@ class TestBugzillaRemoteComponentFinder(TestCaseWithFactory):
121 )
122 responses.add(
123 "GET",
124- re.compile(r".*/newquery\.cgi\?format=advanced"),
125- match_querystring=True,
126+ re.compile(r".*/newquery\.cgi"),
127+ match=[query_string_matcher("format=advanced")],
128 content_type="text/html",
129 body=read_test_file("bugzilla-fdo-advanced-query.html"),
130 )
131diff --git a/requirements/launchpad.txt b/requirements/launchpad.txt
132index a76d45e..356a486 100644
133--- a/requirements/launchpad.txt
134+++ b/requirements/launchpad.txt
135@@ -32,7 +32,6 @@ Chameleon==3.6.2
136 configobj==5.0.6
137 contextvars==2.4
138 constantly==15.1.0
139-cookies==2.2.1
140 cryptography==2.7
141 cssselect==0.9.1
142 cssutils==1.0.2
143@@ -156,7 +155,7 @@ PyYAML==5.3.1
144 rabbitfixture==0.5.3
145 requests-file==1.4.3
146 requests-toolbelt==0.9.1
147-responses==0.9.0
148+responses==0.17.0
149 rfc3986==1.5.0
150 s3transfer==0.3.6
151 secure-cookie==0.1.0

Subscribers

People subscribed via source and target branches

to status/vote changes: