Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Travis CI support. Add functional tests.
- Loading branch information
Showing
15 changed files
with
252 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,30 @@ | ||
sudo: required | ||
dist: trusty | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.3" | ||
- "3.4" | ||
matrix: | ||
include: | ||
- env: TOXENV=py27-dj18 | ||
python: 2.7 | ||
- env: TOXENV=py33-dj18 | ||
python: 3.3 | ||
- env: TOXENV=py34-dj18 | ||
python: 3.4 | ||
- env: TOXENV=py35-dj18 | ||
python: 3.5 | ||
- env: TOXENV=py27-dj19 | ||
python: 2.7 | ||
- env: TOXENV=py34-dj19 | ||
python: 3.4 | ||
- env: TOXENV=py35-dj19 | ||
python: 3.5 | ||
- env: TOXENV=flake8 | ||
python: 3.4 | ||
before_install: | ||
- curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` > docker-compose | ||
- chmod +x docker-compose | ||
- sudo mv docker-compose /usr/local/bin | ||
install: | ||
# Install puput in current directory, install dependencies normally | ||
- python setup.py develop | ||
- pip install tox | ||
script: | ||
- python setup.py test | ||
- docker-compose -f tests/testapp/docker-compose.yaml up -d firefox hub | ||
- tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest==3.0.3 | ||
pytest-splinter==1.7.6 | ||
tox==2.3.1 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def site_url(request): | ||
return request.config.getoption("--site-url") | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption("--site-url", action="store", default="type1", help="url to test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import time | ||
|
||
|
||
class TestBlogPage(object): | ||
|
||
def test_blog_page_home(self, browser, site_url): | ||
browser.visit(site_url + '/blog/') | ||
assert browser.status_code == 200 | ||
assert browser.is_text_present('Blog') | ||
|
||
def test_blog_page_click_search(self, browser, site_url): | ||
browser.visit(site_url + '/blog/') | ||
browser.fill('q', 'test') | ||
button = browser.find_by_css('.btn-default')[0] | ||
button.click() | ||
time.sleep(2) | ||
assert browser.url == site_url + '/blog/search/?q=test' | ||
assert browser.status_code == 200 | ||
assert browser.is_text_present('Entries for search') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
class TestEntryList(object): | ||
|
||
def test_blog_page_entries(self, browser, site_url): | ||
browser.visit(site_url + '/blog/') | ||
entries = browser.find_by_css('.page-content') | ||
assert browser.status_code == 200 | ||
assert len(entries) > 0 | ||
|
||
def test_entry_page_search(self, browser, site_url): | ||
browser.visit(site_url + '/blog/search/?q=test') | ||
entries = browser.find_by_css('.page-content') | ||
assert browser.status_code == 200 | ||
assert browser.is_text_present('search') | ||
assert len(entries) > 0 | ||
|
||
def test_entry_page_author(self, browser, site_url): | ||
browser.visit(site_url + '/blog/author/admin/') | ||
entries = browser.find_by_css('.page-content') | ||
assert browser.status_code == 200 | ||
assert browser.is_text_present('Entries for author') | ||
assert len(entries) > 0 | ||
|
||
def test_entry_page_category(self, browser, site_url): | ||
browser.visit(site_url + '/blog/category/test/') | ||
entries = browser.find_by_css('.page-content') | ||
assert browser.status_code == 200 | ||
assert browser.is_text_present('Entries for category') | ||
assert len(entries) > 0 | ||
|
||
def test_entry_page_tag(self, browser, site_url): | ||
browser.visit(site_url + '/blog/tag/test/') | ||
entries = browser.find_by_css('.page-content') | ||
assert browser.status_code == 200 | ||
assert browser.is_text_present('Entries for tag') | ||
assert len(entries) > 0 | ||
|
||
def test_entry_page_archive_year(self, browser, site_url): | ||
browser.visit(site_url + '/blog/2016/') | ||
entries = browser.find_by_css('.page-content') | ||
assert browser.status_code == 200 | ||
assert browser.is_text_present('Entries for date') | ||
assert len(entries) > 0 | ||
|
||
def test_entry_page_archive_year_month(self, browser, site_url): | ||
browser.visit(site_url + '/blog/2016/08/') | ||
entries = browser.find_by_css('.page-content') | ||
assert browser.status_code == 200 | ||
assert browser.is_text_present('Entries for date') | ||
assert len(entries) > 0 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
hub: | ||
image: selenium/hub | ||
ports: | ||
- "4444:4444" | ||
firefox: | ||
image: selenium/node-firefox | ||
links: | ||
- hub | ||
expose: | ||
- "5555" | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import os | ||
from puput import PUPUT_APPS | ||
|
||
WAGTAIL_SITE_NAME = 'Puput blog' | ||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
SECRET_KEY = 'changemepliz' | ||
DEBUG = True | ||
ALLOWED_HOSTS = "*" | ||
|
||
INSTALLED_APPS = ( | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
) | ||
INSTALLED_APPS += PUPUT_APPS | ||
|
||
MIDDLEWARE_CLASSES = ( | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.common.CommonMiddleware', | ||
'django.middleware.csrf.CsrfViewMiddleware', | ||
'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | ||
'django.contrib.messages.middleware.MessageMiddleware', | ||
'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
'django.middleware.security.SecurityMiddleware', | ||
'wagtail.wagtailcore.middleware.SiteMiddleware', | ||
'wagtail.wagtailredirects.middleware.RedirectMiddleware', | ||
) | ||
|
||
ROOT_URLCONF = 'tests.testapp.urls' | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [], | ||
'APP_DIRS': True, | ||
'OPTIONS': { | ||
'context_processors': [ | ||
'django.template.context_processors.debug', | ||
'django.template.context_processors.request', | ||
'django.contrib.auth.context_processors.auth', | ||
'django.contrib.messages.context_processors.messages', | ||
'django.core.context_processors.request', | ||
], | ||
}, | ||
}, | ||
] | ||
|
||
WSGI_APPLICATION = 'tests.testapp.wsgi.application' | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': 'tests/testapp/puput.db', | ||
'USER': '', | ||
'PASSWORD': '', | ||
} | ||
} | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
TIME_ZONE = 'UTC' | ||
USE_I18N = True | ||
USE_L10N = True | ||
USE_TZ = True | ||
|
||
STATIC_ROOT = '/tmp/static' | ||
STATIC_URL = '/static/' | ||
MEDIA_ROOT = '/tmp/media' | ||
MEDIA_URL = '/media/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.conf import settings | ||
from django.conf.urls import include, url | ||
from django.contrib import admin | ||
from django.conf.urls.static import static | ||
|
||
urlpatterns = [ | ||
url(r'^admin/', include(admin.site.urls)), | ||
url(r'', include('puput.urls')), | ||
] | ||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) | ||
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
WSGI config for blog project. | ||
It exposes the WSGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.wsgi import get_wsgi_application | ||
|
||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.testapp.settings") | ||
|
||
application = get_wsgi_application() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[tox] | ||
envlist = py{27,33,34,35}-dj{18,19}, flake8 | ||
|
||
[flake8] | ||
max-line-length = 120 | ||
|
||
[testenv] | ||
commands = | ||
django-admin collectstatic --noinput --settings=tests.testapp.settings | ||
gunicorn tests.testapp.wsgi -b :8000 -D | ||
pytest --splinter-webdriver=remote --splinter-remote-url=http://localhost:4444/wd/hub --site-url=http://172.17.0.1:8000 | ||
|
||
basepython = | ||
py27: python2.7 | ||
py33: python3.3 | ||
py34: python3.4 | ||
py35: python3.5 | ||
|
||
deps = | ||
pytest==3.0.3 | ||
pytest-splinter==1.7.6 | ||
django-compressor>=1.6 | ||
wagtail>=1.0,<2.0 | ||
django-el-pagination>=2.1.1 | ||
tapioca-disqus==0.1.2 | ||
gunicorn==19.6.0 | ||
|
||
dj18: Django>=1.8.1,<1.9 | ||
dj19: Django>=1.9,<1.10 | ||
[testenv:flake8] | ||
basepython = python3.4 | ||
deps = flake8==3.0.4 | ||
commands = flake8 puput tests --exclude=migrations |