Fixed tests (Closes #11)
This commit is contained in:
parent
3a04c21ab8
commit
b3ed5eefd9
1 changed files with 11 additions and 9 deletions
|
@ -1,17 +1,19 @@
|
||||||
|
from urllib.parse import urlsplit
|
||||||
import unittest
|
import unittest
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
class PagesTestCase(unittest.TestCase):
|
class PagesTestCase(unittest.TestCase):
|
||||||
def test_http_redirect_to_https(self):
|
def test_http_redirect_to_https(self):
|
||||||
result = requests.get('http://fmartingr.com', allow_redirects=False)
|
response = requests.get('http://fmartingr.com', allow_redirects=False)
|
||||||
self.assertEqual(result.status_code, 301)
|
scheme, host, *_ = urlsplit(response.headers.get("Location"))
|
||||||
self.assertEqual(result.headers.get('Location'),
|
self.assertEqual(response.status_code, 301)
|
||||||
'https://fmartingr.com/')
|
self.assertEqual(scheme, 'https')
|
||||||
|
self.assertEquals(host, "fmartingr.com")
|
||||||
|
|
||||||
def test_www_redirects_to_non_www(self):
|
def test_www_redirects_to_non_www(self):
|
||||||
request = requests.get('https://www.fmartingr.com',
|
response = requests.get('https://www.fmartingr.com', allow_redirects=False)
|
||||||
allow_redirects=False)
|
scheme, host, *_ = urlsplit(response.headers.get("Location"))
|
||||||
self.assertEqual(request.status_code, 301)
|
self.assertEqual(response.status_code, 301)
|
||||||
self.assertEqual(request.headers.get('Location'),
|
self.assertEqual(scheme, 'https')
|
||||||
'https://fmartingr.com/')
|
self.assertEquals(host, "fmartingr.com")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue