From 5fb242f421d42e41945212cfceaeafa1860e7655 Mon Sep 17 00:00:00 2001 From: Oliverpool Date: Sun, 3 Jul 2016 22:35:02 +0200 Subject: [PATCH] add custom plugins tests --- test/test_content/custom.control | 1 + test/test_content/custom.source | 1 + .../datadir/python/content/customplugin.py | 21 +++++++++++++++++++ test/test_content/test_content.py | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/test_content/custom.control create mode 100644 test/test_content/custom.source create mode 100755 test/test_content/datadir/python/content/customplugin.py diff --git a/test/test_content/custom.control b/test/test_content/custom.control new file mode 100644 index 00000000..b549c6a3 --- /dev/null +++ b/test/test_content/custom.control @@ -0,0 +1 @@ +- "{'customname:': ''}" \ No newline at end of file diff --git a/test/test_content/custom.source b/test/test_content/custom.source new file mode 100644 index 00000000..ded39db8 --- /dev/null +++ b/test/test_content/custom.source @@ -0,0 +1 @@ +- customname: \ No newline at end of file diff --git a/test/test_content/datadir/python/content/customplugin.py b/test/test_content/datadir/python/content/customplugin.py new file mode 100755 index 00000000..2137198c --- /dev/null +++ b/test/test_content/datadir/python/content/customplugin.py @@ -0,0 +1,21 @@ +"""Fake plugin for test purposes.""" + +from patacrep.content import ContentItem, ContentList, validate_parser_argument + +class FakeContent(ContentItem): + """Fake content.""" + + def render(self, __context): + return 'fakecontent' + + def file_entry(self): + return {'customname:':''} + +#pylint: disable=unused-argument +def parse(keyword, argument, config): + """ + """ + return ContentList([FakeContent()]) + +CONTENT_PLUGINS = {'customname': parse} + diff --git a/test/test_content/test_content.py b/test/test_content/test_content.py index 770d4e1a..bd429bf8 100644 --- a/test/test_content/test_content.py +++ b/test/test_content/test_content.py @@ -93,7 +93,7 @@ class FileTest(unittest.TestCase, metaclass=dynamic.DynamicTest): return files.path2posix(elem.filename) else: - raise Exception(elem) + return str(elem.file_entry()) @classmethod def _generate_config(cls, sbcontent, outputdir, base):