示例#1
0
 def test_exception(self):
     try:
         Attachment.to_parent_element(Attachment(), ns_test)
     except:
         self.assertTrue(True)
     else:
         self.assertFalse(True)
示例#2
0
 def test_exception(self):
     try:
         Attachment.to_parent_element(Attachment(), ns_test)
     except:
         self.assertTrue(True)
     else:
         self.assertFalse(True)
示例#3
0
 def test_to_parent_element_file(self):
     a = Attachment()
     a.file_name = self.tmpfile
     f = open(self.tmpfile, 'rb')
     data = f.read()
     f.close()
     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)
示例#4
0
 def test_to_parent_element_file(self):
     a = Attachment()
     a.file_name = self.tmpfile
     f = open(self.tmpfile, 'rb')
     data = f.read()
     f.close()
     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)
示例#5
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)
示例#6
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)
示例#7
0
    def test_to_from_xml_file(self):
        a = Attachment()
        a.file_name = self.tmpfile
        element = etree.Element('test')
        Attachment.to_parent_element(a, ns_test, element)
        element = element[0]

        data = Attachment.from_xml(element).data

        f = open(self.tmpfile, 'rb')
        fdata = f.read()
        f.close()

        self.assertEquals(data, fdata)
示例#8
0
    def test_to_from_xml_file(self):
        a = Attachment()
        a.file_name = self.tmpfile
        element = etree.Element('test')
        Attachment.to_parent_element(a, ns_test, element)
        element = element[0]

        data = Attachment.from_xml(element).data

        f = open(self.tmpfile, 'rb')
        fdata = f.read()
        f.close()

        self.assertEquals(data, fdata)