diff --git a/.gitignore b/.gitignore index 75a2a90..7deee4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# python +__pycache__ + # node/bower node_modules bower_components @@ -9,3 +12,6 @@ bower_components assets/static/js/app-min.js assets/static/js/app.js assets/static/css + +# Tests +tests/venv diff --git a/Makefile b/Makefile index d9b13e6..4f6ba46 100644 --- a/Makefile +++ b/Makefile @@ -15,3 +15,6 @@ watch: deploy: make build lektor deploy + +deploy_tests: + bash tests/run.sh diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..f229360 --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1 @@ +requests diff --git a/tests/run.sh b/tests/run.sh new file mode 100644 index 0000000..9e55564 --- /dev/null +++ b/tests/run.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +virtualenv -p python3 tests/venv +source tests/venv/bin/activate +pip install -r tests/requirements.txt +python -m unittest tests.tests_deploy diff --git a/tests/tests_deploy.py b/tests/tests_deploy.py new file mode 100644 index 0000000..62f17e6 --- /dev/null +++ b/tests/tests_deploy.py @@ -0,0 +1,18 @@ +import unittest + +import requests + + +class DeployTestCase(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/') + + 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'), + 'http://fmartingr.com/')