From b3ed5eefd939035c855c129d84bd0868c16aeebf Mon Sep 17 00:00:00 2001 From: Felipe Martin Date: Tue, 22 Oct 2019 00:22:41 +0200 Subject: [PATCH] Fixed tests (Closes #11) --- tests/tests_deploy.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/tests_deploy.py b/tests/tests_deploy.py index 13e735e..2e2b131 100644 --- a/tests/tests_deploy.py +++ b/tests/tests_deploy.py @@ -1,17 +1,19 @@ +from urllib.parse import urlsplit import unittest import requests class PagesTestCase(unittest.TestCase): def test_http_redirect_to_https(self): - result = requests.get('http://fmartingr.com', allow_redirects=False) - self.assertEqual(result.status_code, 301) - self.assertEqual(result.headers.get('Location'), - 'https://fmartingr.com/') + response = requests.get('http://fmartingr.com', allow_redirects=False) + scheme, host, *_ = urlsplit(response.headers.get("Location")) + self.assertEqual(response.status_code, 301) + self.assertEqual(scheme, 'https') + self.assertEquals(host, "fmartingr.com") def test_www_redirects_to_non_www(self): - request = requests.get('https://www.fmartingr.com', - allow_redirects=False) - self.assertEqual(request.status_code, 301) - self.assertEqual(request.headers.get('Location'), - 'https://fmartingr.com/') + response = requests.get('https://www.fmartingr.com', allow_redirects=False) + scheme, host, *_ = urlsplit(response.headers.get("Location")) + self.assertEqual(response.status_code, 301) + self.assertEqual(scheme, 'https') + self.assertEquals(host, "fmartingr.com")