Esempio n. 1
0
 def test_catalog_xsd(self):
     T = Transformer([('demo', 'catalog-xsl')],
                     transformer_registry=self.registry)
     result = T(catalog_xml)
     self.assertTrue('<h2>My CD Collection</h2>' in result)
     self.assertTrue('<tr bgcolor="#9acd32">' in result)
     self.assertTrue('<td>Bob Dylan</td>' in result)
Esempio n. 2
0
 def test_transformation_1_and_2(self):
     T = Transformer([('demo', 't1'), ('demo', 't2')],
                     transformer_registry=self.registry)
     result = T(sample_xml)
     self.assertTrue(result.count('<foo>') == 0)
     self.assertTrue(result.count('<bar>') == 3)
     self.assertTrue('<hello foo="bar">' in result)
Esempio n. 3
0
 def test_catalog_python_xsd_transform(self):
     T = Transformer([('demo', 'catalog-python'), ('demo', 'catalog-xsl')],
                     transformer_registry=self.registry)
     result = T(catalog_xml)
     # running catalog-python first should not have any effect
     self.assertTrue('<h2>My CD Collection</h2>' in result)
     self.assertTrue('<tr bgcolor="#9acd32">' in result)
     self.assertTrue('<table' in result)
Esempio n. 4
0
 def test_catalog_xsd_python_transform(self):
     T = Transformer([('demo', 'catalog-xsl'), ('demo', 'catalog-python')],
                     transformer_registry=self.registry)
     result = T(catalog_xml)
     self.assertTrue('<h2>My CD Collection</h2>' in result)
     self.assertTrue('<tr bgcolor="#9acd32">' in result)
     self.assertFalse('<table>' in result)
     self.assertTrue('<TABELLE' in result)
Esempio n. 5
0
 def test_transformation_with_node(self):
     T = Transformer([('demo', 't1')], transformer_registry=self.registry)
     result = T(lxml.etree.fromstring(sample_xml))
     self.assertTrue(result.count('<bar>') == 3)
Esempio n. 6
0
 def test_transformation_1(self):
     T = Transformer([('demo', 't1')], transformer_registry=self.registry)
     result = T(sample_xml)
     self.assertTrue(result.count('<bar>') == 3)
Esempio n. 7
0
 def test_verify_steps_failing(self):
     T = Transformer([('xxx', 'yyy')], transformer_registry=self.registry)
     with self.assertRaises(ValueError):
         T.verify_steps()
Esempio n. 8
0
 def test_verify_steps_working(self):
     T = Transformer([('demo', 't1'), ('demo', 't2')],
                     transformer_registry=self.registry)
     T.verify_steps()
Esempio n. 9
0
 def test_xslt2_transformation(self):
     T = Transformer([('demo', 'sample-xslt2')],
                     transformer_registry=self.registry)
     result = T(sample_xslt2_xml)
     self.assertTrue('<test xmlns="http://www.example.com/v2">' in result)
Esempio n. 10
0
 def test_transformation_with_debug_option(self):
     T = Transformer([('demo', 'catalog-xsl'), ('demo', 'catalog-python')],
                     transformer_registry=self.registry)
     T(catalog_xml, debug=True)
Esempio n. 11
0
 def test_transformation_custom_output_encoding(self):
     T = Transformer([('demo', 't1')], transformer_registry=self.registry)
     result = T(sample_xml, output_encoding='utf16')
     self.assertTrue(not isinstance(result, unicode))
Esempio n. 12
0
 def test_transformation_return_fragment_non_existing_fragment(self):
     T = Transformer([('demo', 't1')], transformer_registry=self.registry)
     with self.assertRaises(ValueError):
         T(sample_xml, return_fragment='XXXXXX')
Esempio n. 13
0
 def test_transformation_return_fragment(self):
     T = Transformer([('demo', 't1')], transformer_registry=self.registry)
     result = T(sample_xml, return_fragment='world')
     self.assertTrue('<hello' not in result)
Esempio n. 14
0
 def test_transformation_2(self):
     T = Transformer([('demo', 't2')], transformer_registry=self.registry)
     result = T(sample_xml)
     self.assertTrue('<hello foo="bar">' in result)
Esempio n. 15
0
 def test_transformation_unicode_without_input_encoding(self):
     T = Transformer([('demo', 't1')], transformer_registry=self.registry)
     with self.assertRaises(TypeError):
         T(sample_xml.encode('utf8'), input_encoding=None)
Esempio n. 16
0
 def test_transformation_improper_root(self):
     T = Transformer([('demo', 't1')], transformer_registry=self.registry)
     with self.assertRaises(TypeError):
         T(object)