summaryrefslogtreecommitdiffstats
path: root/tests/ccs2needle_xslt.py
blob: f5cbf0a68674af065579ea3009b4d1df3e8f17d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: UTF-8 -*-
# Copyright 2015 Red Hat, Inc.
# Part of clufter project
# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt)
"""Testing destilling XSLT from the sparse tree-organized snippets"""
__author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"

from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go'))


from unittest import TestCase
from os.path import dirname, join
from sys import modules

from lxml import etree

from .filter import XMLFilter
from .format_manager import FormatManager

WALK_DIR = join(dirname(modules[XMLFilter.__module__].__file__), 'filters')

class Ccs2NeedleXsltViewOnly(TestCase):
    def setUp(self):
        self.fmt_mgr = fmt_mgr = FormatManager()
        self.formats = fmt_mgr.plugins

    def tearDown(self):
        self.fmt_mgr.registry.setup(True)

    def testXSLTTemplate2(self):
        formats = self.formats
        flt = XMLFilter(formats)
        in_obj = formats['ccs']('file', join(dirname(__file__), 'filled.conf'))
        r = flt.get_template(in_obj, symbol='ccs2needlexml', root_dir=WALK_DIR)
        ret = r if isinstance(r, list) else [r]
        print "\n".join([etree.tostring(i, pretty_print=True) for i in ret])

        assert not isinstance(r, list)


from os.path import join, dirname as d; execfile(join(d(__file__), '_gone'))