Browse Source

test: upgrade responses to 0.10.12 (#16502)

josh 3 years ago
parent
commit
bfdcc4d71e

+ 1 - 1
requirements-dev.txt

@@ -9,5 +9,5 @@ pytest-cov==2.11.1
 pytest-django==3.10.0
 pytest-sentry==0.1.6
 pytest-rerunfailures==9.1.1
-responses>=0.8.1,<0.9.0
+responses==0.10.12
 sqlparse==0.2.4

+ 9 - 5
tests/sentry/integrations/bitbucket/test_integration.py

@@ -1,4 +1,4 @@
-from urllib.parse import quote
+from urllib.parse import quote, urlencode
 
 import responses
 from django.core.urlresolvers import reverse
@@ -44,15 +44,17 @@ class BitbucketIntegrationTest(APITestCase):
 
     @responses.activate
     def test_get_repositories_exact_match(self):
+        querystring = urlencode({"q": 'name="stuf"'})
         responses.add(
             responses.GET,
-            "https://api.bitbucket.org/2.0/repositories/sentryuser?name=stuf",
+            f"https://api.bitbucket.org/2.0/repositories/sentryuser?{querystring}",
             json={"values": [{"full_name": "sentryuser/stuf"}]},
         )
 
+        querystring = urlencode({"q": 'name~"stuf"'})
         responses.add(
             responses.GET,
-            "https://api.bitbucket.org/2.0/repositories/sentryuser?name~stuf",
+            f"https://api.bitbucket.org/2.0/repositories/sentryuser?{querystring}",
             json={
                 "values": [
                     {"full_name": "sentryuser/stuff"},
@@ -90,9 +92,10 @@ class BitbucketIntegrationTest(APITestCase):
 
     @responses.activate
     def test_get_repositories_no_exact_match(self):
+        querystring = urlencode({"q": 'name~"stu"'})
         responses.add(
             responses.GET,
-            "https://api.bitbucket.org/2.0/repositories/sentryuser?name~stuf",
+            f"https://api.bitbucket.org/2.0/repositories/sentryuser?{querystring}",
             json={
                 "values": [
                     {"full_name": "sentryuser/stuff"},
@@ -111,9 +114,10 @@ class BitbucketIntegrationTest(APITestCase):
             },
         )
 
+        querystring = urlencode({"q": 'name="stu"'})
         responses.add(
             responses.GET,
-            "https://api.bitbucket.org/2.0/repositories/sentryuser?name=stuf",
+            f"https://api.bitbucket.org/2.0/repositories/sentryuser?{querystring}",
             json={"values": []},
         )
 

+ 2 - 2
tests/sentry/integrations/bitbucket_server/test_repository.py

@@ -131,13 +131,13 @@ class BitbucketServerRepositoryProviderTest(APITestCase):
 
         responses.add(
             responses.GET,
-            "https://bitbucket.example.com/rest/api/1.0/projects/sentryuser/repos/newsdiffs/commits/042bc8434e0c178d8745c7d9f90bddab9c927887/changes?merges=exclude&limit=100&start=0",
+            "https://bitbucket.example.com/rest/api/1.0/projects/sentryuser/repos/newsdiffs/commits/042bc8434e0c178d8745c7d9f90bddab9c927887/changes?limit=1000&start=0",
             json=COMMIT_CHANGELIST_WITH_PAGES_SECOND_COMMIT_EXAMPLE_1_2,
         )
 
         responses.add(
             responses.GET,
-            "https://bitbucket.example.com/rest/api/1.0/projects/sentryuser/repos/newsdiffs/commits/042bc8434e0c178d8745c7d9f90bddab9c927887/changes?merges=exclude&limit=100&start=1",
+            "https://bitbucket.example.com/rest/api/1.0/projects/sentryuser/repos/newsdiffs/commits/042bc8434e0c178d8745c7d9f90bddab9c927887/changes?limit=1000&start=1",
             json=COMMIT_CHANGELIST_WITH_PAGES_SECOND_COMMIT_EXAMPLE_2_2,
         )
 

+ 2 - 1
tests/sentry/integrations/github/test_integration.py

@@ -216,9 +216,10 @@ class GitHubIntegrationTest(IntegrationTestCase):
         with self.tasks():
             self.assert_setup_flow()
 
+        querystring = urlencode({"q": "org:Test Organization ex"})
         responses.add(
             responses.GET,
-            self.base_url + "/search/repositories?q=org:test%20ex",
+            f"{self.base_url}/search/repositories?{querystring}",
             json={
                 "items": [
                     {"name": "example", "full_name": "test/example"},

+ 2 - 1
tests/sentry/integrations/github_enterprise/test_integration.py

@@ -167,9 +167,10 @@ class GitHubEnterpriseIntegrationTest(IntegrationTestCase):
         with self.tasks():
             self.assert_setup_flow()
 
+        querystring = urlencode({"q": "org:Test Organization ex"})
         responses.add(
             responses.GET,
-            self.base_url + "/search/repositories?q=org:test%20ex",
+            f"{self.base_url}/search/repositories?{querystring}",
             json={
                 "items": [
                     {"name": "example", "full_name": "test/example"},

+ 4 - 4
tests/sentry/integrations/gitlab/test_search.py

@@ -46,7 +46,7 @@ class GitlabSearchTest(GitLabTestCase):
     def test_finds_external_issue_results_with_iid(self):
         responses.add(
             responses.GET,
-            "https://example.gitlab.com/api/v4/projects/5/issues?scope=all&search=25",
+            "https://example.gitlab.com/api/v4/projects/5/issues?scope=all&iids=25",
             json=[{"iid": 25, "title": "AEIOU Error", "project_id": "5"}],
         )
         resp = self.client.get(
@@ -60,7 +60,7 @@ class GitlabSearchTest(GitLabTestCase):
     def test_finds_project_results(self):
         responses.add(
             responses.GET,
-            "https://example.gitlab.com/api/v4/groups/1/projects?query=GetSentry&simple=True",
+            "https://example.gitlab.com/api/v4/groups/1/projects?search=GetSentry&simple=True&include_subgroups=False&page=1&per_page=100",
             json=[
                 {
                     "id": "1",
@@ -136,7 +136,7 @@ class GitlabSearchTest(GitLabTestCase):
     def test_finds_no_external_issues_results_iid(self):
         responses.add(
             responses.GET,
-            "https://example.gitlab.com/api/v4/projects/5/issues?scope=all&search=11",
+            "https://example.gitlab.com/api/v4/projects/5/issues?scope=all&iids=11",
             json=[],
         )
         resp = self.client.get(
@@ -150,7 +150,7 @@ class GitlabSearchTest(GitLabTestCase):
     def test_finds_no_project_results(self):
         responses.add(
             responses.GET,
-            "https://example.gitlab.com/api/v4/groups/1/projects?query=GetSentry&simple=True",
+            "https://example.gitlab.com/api/v4/groups/1/projects?search=GetSentry&simple=True&include_subgroups=False&page=1&per_page=100",
             json=[],
         )
         resp = self.client.get(self.url, data={"field": "project", "query": "GetSentry"})

+ 4 - 4
tests/sentry/integrations/vercel/test_integration.py

@@ -31,11 +31,11 @@ class VercelIntegrationTest(IntegrationTestCase):
         }
 
         if is_team:
-            team_query = "?teamId=my_team_id"
+            team_query = "teamId=my_team_id"
             access_json["team_id"] = "my_team_id"
             responses.add(
                 responses.GET,
-                "https://api.vercel.com/v1/teams/my_team_id%s" % team_query,
+                f"https://api.vercel.com/v1/teams/my_team_id?{team_query}",
                 json={"name": "My Team Name", "slug": "my_team_slug"},
             )
         else:
@@ -53,13 +53,13 @@ class VercelIntegrationTest(IntegrationTestCase):
 
         responses.add(
             responses.GET,
-            "https://api.vercel.com/v4/projects/%s" % team_query,
+            f"https://api.vercel.com/v4/projects/?limit=20&{team_query}",
             json={"projects": [], "pagination": {"count": 0}},
         )
 
         responses.add(
             responses.POST,
-            "https://api.vercel.com/v1/integrations/webhooks%s" % team_query,
+            f"https://api.vercel.com/v1/integrations/webhooks?{team_query}",
             json={"id": "webhook-id"},
         )
 

+ 1 - 1
tests/sentry/integrations/vsts/test_integration.py

@@ -194,7 +194,7 @@ class VstsIntegrationProviderTest(VstsIntegrationTestCase):
 
     @patch("sentry.integrations.vsts.VstsIntegrationProvider.get_scopes", return_value=FULL_SCOPES)
     def test_fix_subscription(self, mock_get_scopes):
-        external_id = "1234567890"
+        external_id = self.vsts_account_id
         Integration.objects.create(metadata={}, provider="vsts", external_id=external_id)
         data = VstsIntegrationProvider().build_integration(
             {

+ 1 - 1
tests/sentry/integrations/vsts/test_issues.py

@@ -120,7 +120,7 @@ class VstsIssueSyncTest(VstsIssueBase):
     def test_create_issue(self):
         responses.add(
             responses.PATCH,
-            "https://fabrikam-fiber-inc.visualstudio.com/0987654321/_apis/wit/workitems/$Microsoft.VSTS.WorkItemTypes.Task?api-version=3.0",
+            "https://fabrikam-fiber-inc.visualstudio.com/0987654321/_apis/wit/workitems/$Microsoft.VSTS.WorkItemTypes.Task",
             body=WORK_ITEM_RESPONSE,
             content_type="application/json",
         )

+ 1 - 1
tests/sentry/integrations/vsts/test_notify_action.py

@@ -53,7 +53,7 @@ class AzureDevopsCreateTicketActionTest(RuleTestCase, VstsIssueBase):
         azuredevops_rule.rule = Rule.objects.create(project=self.project, label="test rule")
         responses.add(
             responses.PATCH,
-            "https://fabrikam-fiber-inc.visualstudio.com/0987654321/_apis/wit/workitems/$Microsoft.VSTS.WorkItemTypes.Task?api-version=3.0",
+            "https://fabrikam-fiber-inc.visualstudio.com/0987654321/_apis/wit/workitems/$Microsoft.VSTS.WorkItemTypes.Task",
             body=WORK_ITEM_RESPONSE,
             content_type="application/json",
         )

Some files were not shown because too many files changed in this diff