Skip to content

Commit

Permalink
Added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vdboor committed Aug 7, 2016
1 parent 73a1d3d commit e8b708d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fluentcms_cookielaw/tests.py
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>')
45 changes: 45 additions & 0 deletions runtests.py
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()

0 comments on commit e8b708d

Please sign in to comment.