From e8b708daaa0fa6c1796b1e6f43f44972e3719ff6 Mon Sep 17 00:00:00 2001 From: Diederik van der Boor Date: Sun, 7 Aug 2016 21:11:20 +0200 Subject: [PATCH] Added tests --- fluentcms_cookielaw/tests.py | 26 +++++++++++++++++++++ runtests.py | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 fluentcms_cookielaw/tests.py create mode 100755 runtests.py diff --git a/fluentcms_cookielaw/tests.py b/fluentcms_cookielaw/tests.py new file mode 100644 index 0000000..76167de --- /dev/null +++ b/fluentcms_cookielaw/tests.py @@ -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, + '''
+
+ Jummie! + Do you like cookies? +
+
''') + self.assertHTMLEqual(output.media, '') diff --git a/runtests.py b/runtests.py new file mode 100755 index 0000000..d3ce8dd --- /dev/null +++ b/runtests.py @@ -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()