示例#1
0
 def test_to_parent_element_data(self):
     f = open(self.tmpfile)
     data = f.read()
     f.close()
     a = Attachment()
     a.data = data
     element = etree.Element('test')
     Attachment.to_parent_element(a, ns_test, element)
     element = element[0]
     encoded_data = base64.encodestring(data)
     self.assertNotEquals(element.text, None)
     self.assertEquals(element.text, encoded_data)
示例#2
0
 def test_to_parent_element_data(self):
     f = open(self.tmpfile)
     data = f.read()
     f.close()
     a = Attachment()
     a.data = data
     element = etree.Element('test')
     Attachment.to_parent_element(a, ns_test, element)
     element = element[0]
     encoded_data = base64.encodestring(data)
     self.assertNotEquals(element.text, None)
     self.assertEquals(element.text, encoded_data)
示例#3
0
    def test_from_xml(self):
        f = open(self.tmpfile)
        data = f.read()
        f.close()

        a = Attachment()
        a.data = data
        element = etree.Element('test')
        Attachment.to_parent_element(a, ns_test, element)
        element = element[0]
        a2 = Attachment.from_xml(element)

        self.assertEquals(data, a2.data)
示例#4
0
    def test_from_xml(self):
        f = open(self.tmpfile)
        data = f.read()
        f.close()

        a = Attachment()
        a.data = data
        element = etree.Element('test')
        Attachment.to_parent_element(a, ns_test, element)
        element = element[0]
        a2 = Attachment.from_xml(element)

        self.assertEquals(data, a2.data)