Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felliott/bfce4b1ee15556f2a7c8 to your computer and use it in GitHub Desktop.
Save felliott/bfce4b1ee15556f2a7c8 to your computer and use it in GitHub Desktop.
Patch for failing test in django-rest-swagger
From b2c263c6e9e5e9150e02a25682d1861ab530e6f3 Mon Sep 17 00:00:00 2001
From: Fitz Elliott <fitz@cos.io>
Date: Thu, 15 Oct 2015 12:11:29 -0400
Subject: [PATCH] Fix failing test for Swagger-UI 2.1 update
An old test for https protocol preservation was searching for a static
string in the response content. The reponse format changed, so the test
has been updated to search for the https url via regex instead, which will
hopefully be more future-proof.
diff --git a/rest_framework_swagger/tests.py b/rest_framework_swagger/tests.py
index f68acd2..987593b 100644
--- a/rest_framework_swagger/tests.py
+++ b/rest_framework_swagger/tests.py
@@ -2,6 +2,7 @@ import datetime
import platform
import functools
import os
+import re
import copy
import os.path
from mock import Mock, patch
@@ -108,7 +109,7 @@ class HTTPSTest(TestCase):
response = self.client.get("/swagger/",
**{'wsgi.url_scheme': 'https'})
content = response.content.decode()
- self.assertIn("url: 'https", content)
+ self.assertTrue(re.search(r'https://[^/]+/swagger/', content))
def test_api_docs(self):
from django.utils.six.moves.urllib import parse
--
2.6.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment