-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52ee84e
commit 0cbf567
Showing
25 changed files
with
334 additions
and
17 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,5 +1,7 @@ | ||
__pycache__/ | ||
.cache/ | ||
.coverage | ||
coverage.xml | ||
.DS_Store | ||
*.sqlite3 | ||
*.egg-info/ | ||
|
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,14 @@ | ||
sudo: false | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.5" | ||
install: | ||
- pip uninstall pytest -y | ||
- pip install coveralls | ||
- pip install -e .[test] | ||
script: | ||
- py.test --cov=wagtailthemes --cov-report=xml | ||
- flake8 src/ | ||
after_success: | ||
- coveralls |
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,7 +1,19 @@ | ||
all: clean install | ||
all: install clean test lint | ||
|
||
clean: | ||
find . -name '*.pyc' | xargs rm | ||
find . -type f -name "*.py[co]" -delete | ||
find . -type d -name "__pycache__" -delete | ||
|
||
flake8: | ||
flake8 src/ | ||
|
||
install: | ||
pip install -e . | ||
pip install -e .[test] | ||
|
||
isort: | ||
isort --check-only --diff --recursive src/ | ||
|
||
lint: flake8 isort | ||
|
||
test: | ||
py.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
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,2 +1,15 @@ | ||
[coverage:run] | ||
omit=src/wagtailthemes/tests/*,src/wagtailthemes/migrations/* | ||
|
||
[isort] | ||
line_length=80 | ||
|
||
[flake8] | ||
exclude=src/wagtailthemes/migrations/ | ||
max-line-length=80 | ||
|
||
[tool:pytest] | ||
DJANGO_SETTINGS_MODULE=wagtailthemes.tests.settings | ||
|
||
[wheel] | ||
universal=1 |
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
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
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 @@ | ||
pytest_plugins = 'wagtailthemes.tests.fixtures' |
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,29 @@ | ||
import pytest | ||
from django.test import Client | ||
from wagtail.wagtailcore.models import Page, Site | ||
|
||
from wagtailthemes.models import ThemeSettings | ||
|
||
|
||
@pytest.fixture | ||
def page(): | ||
page = Page.objects.get(slug='home') | ||
return page | ||
|
||
|
||
@pytest.fixture | ||
def site(): | ||
site = Site.objects.get(is_default_site=True) | ||
return site | ||
|
||
|
||
@pytest.fixture | ||
def client(): | ||
client = Client() | ||
return client | ||
|
||
|
||
@pytest.fixture | ||
def settings(site): | ||
settings = ThemeSettings.for_site(site) | ||
return settings |
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,29 @@ | ||
import pytest | ||
from django.core.exceptions import ImproperlyConfigured | ||
from django.test.utils import override_settings | ||
|
||
from wagtailthemes.thread import get_theme, set_theme | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_middleware_not_configured(client): | ||
with override_settings(MIDDLEWARE_CLASSES=[ | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.common.CommonMiddleware', | ||
'wagtailthemes.middleware.ThemeMiddleware', | ||
'wagtail.wagtailcore.middleware.SiteMiddleware', | ||
]): | ||
with pytest.raises(ImproperlyConfigured): | ||
client.get('/') | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_middleware_set_theme_for_site(client, site, settings): | ||
settings.theme = 'personal' | ||
settings.save() | ||
|
||
set_theme('wagtail') | ||
assert get_theme() == 'wagtail' | ||
|
||
client.get('/') | ||
assert get_theme() == 'personal' |
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,123 @@ | ||
import os | ||
|
||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
|
||
ALLOWED_HOSTS = [ | ||
'testserver' | ||
] | ||
|
||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.sqlite3', | ||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), | ||
} | ||
} | ||
|
||
DEBUG = True | ||
|
||
INSTALLED_APPS = [ | ||
'django.contrib.admin', | ||
'django.contrib.auth', | ||
'django.contrib.contenttypes', | ||
'django.contrib.sessions', | ||
'django.contrib.messages', | ||
'django.contrib.staticfiles', | ||
|
||
'wagtail.wagtailforms', | ||
'wagtail.wagtailredirects', | ||
'wagtail.wagtailembeds', | ||
'wagtail.wagtailsites', | ||
'wagtail.wagtailusers', | ||
'wagtail.wagtailsnippets', | ||
'wagtail.wagtaildocs', | ||
'wagtail.wagtailimages', | ||
'wagtail.wagtailsearch', | ||
'wagtail.wagtailadmin', | ||
'wagtail.wagtailcore', | ||
|
||
'modelcluster', | ||
'taggit', | ||
|
||
'wagtailthemes', | ||
] | ||
|
||
LANGUAGES = [ | ||
('en', 'English'), | ||
('nl', 'Dutch'), | ||
] | ||
|
||
LANGUAGE_CODE = 'en-us' | ||
|
||
LOCALE_PATHS = [ | ||
os.path.join(BASE_DIR, 'locale'), | ||
] | ||
|
||
MEDIA_URL = '/media/' | ||
MEDIA_ROOT = os.path.join(BASE_DIR, 'public/media') | ||
|
||
MIDDLEWARE_CLASSES = [ | ||
'django.middleware.security.SecurityMiddleware', | ||
'django.contrib.sessions.middleware.SessionMiddleware', | ||
'django.middleware.locale.LocaleMiddleware', | ||
'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', | ||
'wagtail.wagtailcore.middleware.SiteMiddleware', | ||
'wagtail.wagtailredirects.middleware.RedirectMiddleware', | ||
'wagtailthemes.middleware.ThemeMiddleware', | ||
] | ||
|
||
PASSWORD_HASHERS = ( | ||
'django.contrib.auth.hashers.MD5PasswordHasher', | ||
) | ||
|
||
ROOT_URLCONF = 'wagtailthemes.tests.urls' | ||
|
||
SECRET_KEY = '7b&ova34-9b(dj$gevm65$lc!m3#^#g1z*v#gv-g8k0wlo7#l8' | ||
|
||
STATIC_URL = '/static/' | ||
STATIC_ROOT = os.path.join(BASE_DIR, 'public/static') | ||
STATICFILES_DIRS = [ | ||
os.path.join(BASE_DIR, 'static') | ||
] | ||
|
||
TEMPLATES = [ | ||
{ | ||
'BACKEND': 'django.template.backends.django.DjangoTemplates', | ||
'DIRS': [ | ||
os.path.join(BASE_DIR, 'tests', 'templates'), | ||
], | ||
'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', | ||
], | ||
'loaders': [ | ||
'wagtailthemes.loaders.ThemeLoader', | ||
'django.template.loaders.filesystem.Loader', | ||
'django.template.loaders.app_directories.Loader', | ||
] | ||
}, | ||
}, | ||
] | ||
|
||
TIME_ZONE = 'UTC' | ||
|
||
USE_I18N = True | ||
USE_L10N = True | ||
USE_TZ = True | ||
|
||
WAGTAIL_SITE_NAME = 'Wagtail Themes' | ||
|
||
# Wagtail themes | ||
|
||
WAGTAIL_THEME_PATH = None | ||
WAGTAIL_THEMES = [ | ||
('brand', 'Brand site'), | ||
('personal', 'Personal site') | ||
] |
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 @@ | ||
{% block title %}{% endblock %}{% block appendix %}Base{% endblock %} |
Oops, something went wrong.