Colin Watson has proposed merging ~cjwatson/launchpad:responses-0.17.0 into launchpad:master.
Commit message: Upgrade to responses 0.17.0 Requested reviews: Launchpad code reviewers (launchpad-reviewers) For more details, see: https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/446347 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 -- Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:responses-0.17.0 into launchpad:master.
diff --git a/lib/lp/archivepublisher/tests/artifactory_fixture.py b/lib/lp/archivepublisher/tests/artifactory_fixture.py index 52098a3..95f6d75 100644 --- a/lib/lp/archivepublisher/tests/artifactory_fixture.py +++ b/lib/lp/archivepublisher/tests/artifactory_fixture.py @@ -46,7 +46,6 @@ class FakeArtifactoryFixture(Fixture): method="GET", url=repo_url_regex, callback=self._handle_download, - stream=True, ) ) self.requests_mock.add_callback( diff --git a/lib/lp/bugs/doc/sourceforge-remote-products.rst b/lib/lp/bugs/doc/sourceforge-remote-products.rst index 45c09f9..6367fd5 100644 --- a/lib/lp/bugs/doc/sourceforge-remote-products.rst +++ b/lib/lp/bugs/doc/sourceforge-remote-products.rst @@ -81,11 +81,24 @@ Define some request mocks so that we don't try to access SourceForge. ... with open(file_path) as test_file: ... return (200, {}, test_file.read()) ... + >>> def match_group_id(request): + ... request_query = urlsplit(request.url).query + ... if re.match(r"group_id=[0-9]+.*", request_query) is not None: + ... return True, "" + ... else: + ... return ( + ... False, + ... "Query string doesn't match. " + ... "{} doesn't match group_id=[0-9]+.*".format( + ... request_query + ... ), + ... ) + ... >>> def add_tracker_response(requests_mock): ... requests_mock.add_callback( ... "GET", - ... re.compile(r".*/tracker/\?group_id=[0-9]+"), - ... match_querystring=True, + ... re.compile(r".*/tracker/"), + ... match=[match_group_id], ... callback=tracker_callback, ... ) ... diff --git a/lib/lp/bugs/externalbugtracker/tests/test_gitlab.py b/lib/lp/bugs/externalbugtracker/tests/test_gitlab.py index cb53149..f9acca7 100644 --- a/lib/lp/bugs/externalbugtracker/tests/test_gitlab.py +++ b/lib/lp/bugs/externalbugtracker/tests/test_gitlab.py @@ -9,6 +9,7 @@ from urllib.parse import parse_qs, urlsplit, urlunsplit import responses import transaction +from responses.matchers import query_string_matcher from testtools.matchers import ( Contains, ContainsDict, @@ -300,10 +301,9 @@ class TestGitLabUpdateBugWatches(TestCaseWithFactory): ] responses.add( "GET", - "https://gitlab.com/api/v4/projects/user%2Frepository/issues?" - "iids%5B%5D=1234", + "https://gitlab.com/api/v4/projects/user%2Frepository/issues", json=remote_bug, - match_querystring=True, + match=[query_string_matcher("iids%5B%5D=1234")], ) bug = self.factory.makeBug() bug_tracker = self.factory.makeBugTracker( diff --git a/lib/lp/bugs/tests/test_bugtracker.py b/lib/lp/bugs/tests/test_bugtracker.py index 6bb19ca..bcc3d1a 100644 --- a/lib/lp/bugs/tests/test_bugtracker.py +++ b/lib/lp/bugs/tests/test_bugtracker.py @@ -9,6 +9,7 @@ from urllib.parse import urlencode import responses import transaction from lazr.lifecycle.snapshot import Snapshot +from responses.matchers import query_string_matcher from storm.store import Store from testtools.matchers import Equals, MatchesListwise, MatchesStructure from zope.component import getUtility @@ -288,9 +289,12 @@ class TestMantis(TestCaseWithFactory): ) responses.add( "GET", - "http://mantis.example.com/login.php?" - "username=guest&password=guest&return=%2Fsome%2Fpage", - match_querystring=True, + "http://mantis.example.com/login.php", + match=[ + query_string_matcher( + "username=guest&password=guest&return=%2Fsome%2Fpage" + ) + ], status=200, body="sentinel", ) diff --git a/lib/lp/bugs/tests/test_bzremotecomponentfinder.py b/lib/lp/bugs/tests/test_bzremotecomponentfinder.py index 47480f2..3e2c210 100644 --- a/lib/lp/bugs/tests/test_bzremotecomponentfinder.py +++ b/lib/lp/bugs/tests/test_bzremotecomponentfinder.py @@ -8,6 +8,7 @@ from typing import List import responses import transaction +from responses.matchers import query_string_matcher from lp.bugs.scripts.bzremotecomponentfinder import ( BugzillaRemoteComponentFinder, @@ -168,8 +169,8 @@ class TestBugzillaRemoteComponentFinder(TestCaseWithFactory): finder = BugzillaRemoteComponentFinder(logger=BufferLogger()) responses.add( "GET", - re.compile(r".*/query\.cgi\?format=advanced"), - match_querystring=True, + re.compile(r".*/query\.cgi"), + match=[query_string_matcher("format=advanced")], content_type="text/html", body=read_test_file("bugzilla-fdo-advanced-query.html"), ) @@ -202,8 +203,8 @@ class TestBugzillaRemoteComponentFinder(TestCaseWithFactory): ) responses.add( "GET", - re.compile(r".*/newquery\.cgi\?format=advanced"), - match_querystring=True, + re.compile(r".*/newquery\.cgi"), + match=[query_string_matcher("format=advanced")], content_type="text/html", body=read_test_file("bugzilla-fdo-advanced-query.html"), ) diff --git a/requirements/launchpad.txt b/requirements/launchpad.txt index a76d45e..356a486 100644 --- a/requirements/launchpad.txt +++ b/requirements/launchpad.txt @@ -32,7 +32,6 @@ Chameleon==3.6.2 configobj==5.0.6 contextvars==2.4 constantly==15.1.0 -cookies==2.2.1 cryptography==2.7 cssselect==0.9.1 cssutils==1.0.2 @@ -156,7 +155,7 @@ PyYAML==5.3.1 rabbitfixture==0.5.3 requests-file==1.4.3 requests-toolbelt==0.9.1 -responses==0.9.0 +responses==0.17.0 rfc3986==1.5.0 s3transfer==0.3.6 secure-cookie==0.1.0
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : launchpad-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp