configurationengine/source/plugins/symbian/ConeGenconfmlPlugin/genconfmlplugin/tests/unittest_xslttransformer.py
equal
deleted
inserted
replaced
12 # Contributors: |
12 # Contributors: |
13 # |
13 # |
14 # Description: |
14 # Description: |
15 # |
15 # |
16 |
16 |
17 import unittest, os, shutil, sys |
17 import unittest, os, sys |
18 |
18 |
19 import __init__ |
|
20 from genconfmlplugin import xslttransformer |
19 from genconfmlplugin import xslttransformer |
21 from cone.public import exceptions,plugin,api |
|
22 from cone.storage import filestorage |
|
23 from cone.confml import implml |
|
24 |
20 |
25 # Hardcoded value of testdata folder that must be under the current working dir |
21 # Hardcoded value of testdata folder that must be under the current working dir |
26 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
22 ROOT_PATH = os.path.dirname(os.path.abspath(__file__)) |
27 testdata = os.path.join(ROOT_PATH,'project') |
23 testdata = os.path.join(ROOT_PATH,'project') |
|
24 expected = u'<html><body>\r\n<h2>My CD Collection</h2>\r\n<table border="1">\r\n<tr bgcolor="#9acd32">\r\n<th>Title</th>\r\n<th>Artist</th>\r\n</tr>\r\n<tr>\r\n<td>.</td>\r\n<td>.</td>\r\n</tr>\r\n</table>\r\n</body></html>\r\n\r\n'.replace('\r\n', os.linesep) |
28 |
25 |
29 class TestGenconfmlPlugin(unittest.TestCase): |
26 |
|
27 class TestXstlTransformer(unittest.TestCase): |
30 def setUp(self): |
28 def setUp(self): |
31 self.curdir = os.getcwd() |
29 self.curdir = os.getcwd() |
32 self.output = 'output' |
30 self.output = 'output' |
33 pass |
31 pass |
34 |
32 |
38 def test_transform(self): |
36 def test_transform(self): |
39 ''' |
37 ''' |
40 Test that the xslt transformation works |
38 Test that the xslt transformation works |
41 ''' |
39 ''' |
42 transformer = xslttransformer.XsltTransformer() |
40 transformer = xslttransformer.XsltTransformer() |
43 transformer.transform_lxml(os.path.join(ROOT_PATH,"xslt\cdcatalog.xml"), |
41 result = transformer.transform_lxml(os.path.join(ROOT_PATH,"xslt/cdcatalog.xml"), |
44 os.path.join(ROOT_PATH,"xslt\cdcatalog_ex1.xsl"), |
42 os.path.join(ROOT_PATH,"xslt/cdcatalog_ex1.xsl"), |
45 "testioutput.xml", |
|
46 sys.getdefaultencoding()) |
43 sys.getdefaultencoding()) |
47 os.unlink("testioutput.xml") |
44 self.assertEquals(result, expected) |
48 |
45 |
49 |
46 |
50 if __name__ == '__main__': |
47 if __name__ == '__main__': |
51 unittest.main() |
48 unittest.main() |