Browse Source

py3(django): vendored plugins compatibility with Django 1.9 (#15402)

josh 5 years ago
parent
commit
84f5b90e66

+ 6 - 0
.travis.yml

@@ -178,6 +178,11 @@ matrix:
       name: 'Plugins'
       env: TEST_SUITE=plugins DB=postgres PERCY_TOKEN=${PLUGIN_PERCY_TOKEN}
 
+    # allowed to fail
+    - <<: *acceptance_default
+      name: 'Django 1.9 Plugins'
+      env: DJANGO_VERSION=">=1.9,<1.10" TEST_SUITE=plugins DB=postgres PERCY_TOKEN=${PLUGIN_PERCY_TOKEN}
+
     - python: 2.7
       name: 'Frontend'
       env: TEST_SUITE=js
@@ -264,6 +269,7 @@ matrix:
     - name: 'Django 1.9 Backend [Postgres] (2/2)'
     - name: 'Django 1.9 Acceptance'
     - name: 'Plugins'
+    - name: 'Django 1.9 Plugins'
 
 notifications:
   webhooks:

+ 5 - 1
src/new_sentry_plugins/asana/client.py

@@ -15,7 +15,11 @@ class AsanaClient(AuthApiClient):
         return self.get("/tasks/%s" % issue_id)
 
     def create_issue(self, workspace, data):
-        asana_data = {"name": data["title"], "notes": data["description"], "workspace": text_type(workspace)}
+        asana_data = {
+            "name": data["title"],
+            "notes": data["description"],
+            "workspace": text_type(workspace),
+        }
         if data.get("project"):
             asana_data["projects"] = [text_type(data["project"])]
 

+ 5 - 1
src/new_sentry_plugins/base.py

@@ -7,7 +7,11 @@ import sys
 
 from sentry.exceptions import InvalidIdentity, PluginError
 
-from new_sentry_plugins.constants import ERR_INTERNAL, ERR_UNAUTHORIZED, ERR_UNSUPPORTED_RESPONSE_TYPE
+from new_sentry_plugins.constants import (
+    ERR_INTERNAL,
+    ERR_UNAUTHORIZED,
+    ERR_UNSUPPORTED_RESPONSE_TYPE,
+)
 from new_sentry_plugins.exceptions import (
     ApiError,
     ApiHostError,

+ 3 - 3
src/new_sentry_plugins/client.py

@@ -1,12 +1,12 @@
 from __future__ import absolute_import
 
+from collections import OrderedDict
 import logging
 import json
 import requests
 
 from BeautifulSoup import BeautifulStoneSoup
 from cached_property import cached_property
-from django.utils.datastructures import SortedDict
 from requests.exceptions import ConnectionError, HTTPError
 
 from sentry.http import build_session
@@ -59,7 +59,7 @@ class BaseApiResponse(object):
         # to decode it anyways
         if "application/json" not in response.headers["Content-Type"]:
             try:
-                data = json.loads(response.text, object_pairs_hook=SortedDict)
+                data = json.loads(response.text, object_pairs_hook=OrderedDict)
             except (TypeError, ValueError):
                 if allow_text:
                     return TextApiResponse(response.text, response.headers, response.status_code)
@@ -67,7 +67,7 @@ class BaseApiResponse(object):
                     response.headers["Content-Type"], response.status_code
                 )
         else:
-            data = json.loads(response.text, object_pairs_hook=SortedDict)
+            data = json.loads(response.text, object_pairs_hook=OrderedDict)
 
         if isinstance(data, dict):
             return MappingApiResponse(data, response.headers, response.status_code)

+ 1 - 1
src/new_sentry_plugins/victorops/plugin.py

@@ -88,7 +88,7 @@ class VictorOpsPlugin(CorePluginMixin, NotifyPlugin):
                 timestamp=int(event.datetime.strftime("%s")),
                 issue_url=group.get_absolute_url(),
                 issue_id=group.id,
-                project_id=group.project.id
+                project_id=group.project.id,
             )
         except ApiError as e:
             message = "Could not communicate with victorops. Got %s" % e

+ 2 - 1
tests/sentry_plugins/amazon_sqs/test_plugin.py

@@ -75,7 +75,8 @@ class AmazonSQSPluginTest(PluginTestCase):
         self.run_test()
         assert len(logger.info.call_args_list) == 1
         assert (
-            logger.info.call_args_list[0][0][0] == "new_sentry_plugins.amazon_sqs.access_token_invalid"
+            logger.info.call_args_list[0][0][0]
+            == "new_sentry_plugins.amazon_sqs.access_token_invalid"
         )
 
     @patch("new_sentry_plugins.amazon_sqs.plugin.logger")