def test__element_minimal_sld_on_construction(self):
     """_Slide._element is minimal sld on construction"""
     # setup ------------------------
     path = os.path.join(thisdir, 'test_files/minimal_slide.xml')
     # exercise ---------------------
     elm = self.sld._element
     # verify -----------------------
     with open(path, 'r') as f:
         expected = f.read()
     actual = prettify_nsdecls(
         oxml_tostring(elm, encoding='UTF-8', pretty_print=True,
                       standalone=True))
     msg = "\nexpected:\n\n'%s'\n\nbut got:\n\n'%s'" % (expected, actual)
     self.assertEqual(expected, actual, msg)
 def test___minimal_element_xml(self):
     """_Slide.__minimal_element generates correct XML"""
     # setup ------------------------
     path = os.path.join(thisdir, 'test_files/minimal_slide.xml')
     # exercise ---------------------
     sld = self.sld._Slide__minimal_element
     # verify -----------------------
     with open(path, 'r') as f:
         expected_xml = f.read()
     sld_xml = prettify_nsdecls(
         oxml_tostring(sld, encoding='UTF-8', pretty_print=True,
                       standalone=True))
     sld_xml_lines = sld_xml.split('\n')
     expected_xml_lines = expected_xml.split('\n')
     for idx, line in enumerate(sld_xml_lines):
         # msg = '\n\n%s' % sld_xml
         msg = "expected:\n%s\n, got\n%s" % (expected_xml, sld_xml)
         self.assertEqual(line, expected_xml_lines[idx], msg)
Пример #3
0
 def test_construction_xml(self):
     """CT_Shape() produces correct XML on construction"""
     # setup -----------------------
     sp = CT_Shape()
     sp.nvSpPr.cNvPr.id      = 2
     sp.nvSpPr.cNvPr.name    = 'TextBox 1'
     sp.nvSpPr.cNvSpPr.txBox = 1
     sp.spPr.xfrm.off.x      = 1997289
     sp.spPr.xfrm.off.y      = 2529664
     sp.spPr.xfrm.ext.cx     = 2390398
     sp.spPr.xfrm.ext.cy     =  369332
     sp.spPr.prstGeom.prst   = 'rect'
     sp.txBody.bodyPr.wrap   = 'none'
     # exercise --------------------
     xml = etree.tostring(sp.element, encoding='UTF-8',
                          pretty_print=True, standalone=True)
     xml = prettify_nsdecls(xml)
     xml_lines = xml.split('\n')
     txbox_xml_lines = txbox_xml().split('\n')
     # verify ----------------------
     # self.assertTrue(False, xml)
     for idx, line in enumerate(xml_lines):
         assert_that(line, is_(equal_to(txbox_xml_lines[idx])))