-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
2 changed files
with
71 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from django.test import TestCase | ||
from fluent_contents.tests.factories import create_content_item | ||
from fluent_contents.tests.utils import render_content_items | ||
from fluentcms_cookielaw.models import CookieLawItem | ||
|
||
|
||
class CookieLawTests(TestCase): | ||
""" | ||
Testing private notes | ||
""" | ||
|
||
def test_rendering(self): | ||
""" | ||
Test the standard button | ||
""" | ||
item = create_content_item(CookieLawItem, text="Do you like cookies?", button_text="Jummie!") | ||
output = render_content_items([item]) | ||
|
||
self.assertHTMLEqual(output.html, | ||
'''<div id="cookielaw-banner"> | ||
<div class="container"> | ||
<a class="btn" href="javascript:Cookielaw.accept();">Jummie!</a> | ||
Do you like cookies? | ||
</div> | ||
</div>''') | ||
self.assertHTMLEqual(output.media, '<script type="text/javascript" src="/static/fluentcms_cookielaw/js/cookielaw.js"></script>') |
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,45 @@ | ||
#!/usr/bin/env python | ||
import sys | ||
import django | ||
from django.conf import settings, global_settings as default_settings | ||
from django.core.management import execute_from_command_line | ||
|
||
if not settings.configured: | ||
settings.configure( | ||
DATABASES = { | ||
'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:',}, | ||
}, | ||
SITE_ID = 1, | ||
TEMPLATE_LOADERS = ( | ||
'django.template.loaders.app_directories.Loader', | ||
), | ||
TEMPLATE_CONTEXT_PROCESSORS = list(default_settings.TEMPLATE_CONTEXT_PROCESSORS) + [ | ||
'django.core.context_processors.request', | ||
], | ||
INSTALLED_APPS = ( | ||
'django.contrib.contenttypes', | ||
'django.contrib.auth', | ||
'django.contrib.sites', | ||
'fluent_contents', | ||
'fluent_contents.tests.testapp', | ||
'fluentcms_cookielaw', | ||
), | ||
MIDDLEWARE_CLASSES = (), | ||
FLUENT_CONTENTS_CACHE_OUTPUT = False, | ||
TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner' if django.VERSION < (1,6) else 'django.test.runner.DiscoverRunner', | ||
STATIC_URL = '/static/' | ||
) | ||
|
||
DEFAULT_TEST_APPS = [ | ||
'fluentcms_cookielaw', | ||
] | ||
|
||
|
||
def runtests(): | ||
other_args = list(filter(lambda arg: arg.startswith('-'), sys.argv[1:])) | ||
test_apps = list(filter(lambda arg: not arg.startswith('-'), sys.argv[1:])) or DEFAULT_TEST_APPS | ||
argv = sys.argv[:1] + ['test', '--traceback'] + other_args + test_apps | ||
execute_from_command_line(argv) | ||
|
||
if __name__ == '__main__': | ||
runtests() |