Exemplo n.º 1
0
 def test_Valid_1(self):
     tmp_file = None
     tmp_file = self.temp_file_name()
     f = open(tmp_file,'w')
     formatter = XMLFormatter()
     formatter.configure({'name':'xmlformatter','parent':_Parent()})
     stream = formatter.format(self.data)
     output = ''
     data = stream.read(1024)
     while data:
         output += data
         data = stream.read(1024)
     f.write(output)
     f.close()
     command = 'xmllint ' + str(tmp_file)
     stdin, stdout,stderr = os.popen3(command)
     out  = stdout.readlines()
     err = stderr.readlines()
     if err:
         error = ''
         for e in err:
             error += e + '\n'
             pass
         self.fail('File is not a valid XML file:\n' + error)
     return
Exemplo n.º 2
0
 def test_Valid_1(self):
     tmp_file = None
     tmp_file = self.temp_file_name()
     f = open(tmp_file, 'w')
     formatter = XMLFormatter()
     formatter.configure({'name': 'xmlformatter', 'parent': _Parent()})
     stream = formatter.format(self.data)
     output = ''
     data = stream.read(1024)
     while data:
         output += data
         data = stream.read(1024)
     f.write(output)
     f.close()
     command = 'xmllint ' + str(tmp_file)
     stdin, stdout, stderr = os.popen3(command)
     out = stdout.readlines()
     err = stderr.readlines()
     if err:
         error = ''
         for e in err:
             error += e + '\n'
             pass
         self.fail('File is not a valid XML file:\n' + error)
     return
Exemplo n.º 3
0
 def test_timestamp_exception(self):
     formatter = XMLFormatter()
     formatter.configure({'name':'xmlformatter','parent':_Parent()})
     data =[]
     for x in range(1,10):
         entry = {}
         entry['column-A'] = x
         data.append(entry)
     try:
         xml = formatter.format(data)
         while xml.read(100):
             pass
         self.fail('If no timestamp field it should throw an EIncompatiableFormat')
     except EIncompatiableFormat:
         pass
Exemplo n.º 4
0
 def test_timestamp_exception(self):
     formatter = XMLFormatter()
     formatter.configure({'name': 'xmlformatter', 'parent': _Parent()})
     data = []
     for x in range(1, 10):
         entry = {}
         entry['column-A'] = x
         data.append(entry)
     try:
         xml = formatter.format(data)
         while xml.read(100):
             pass
         self.fail(
             'If no timestamp field it should throw an EIncompatiableFormat'
         )
     except EIncompatiableFormat:
         pass
Exemplo n.º 5
0
    def test_DTD_1(self):
        try:
            tmp_file = None
            tmp_file = self.temp_file_name()
            tmp_file2 = self.temp_file_name()
            f2 = open(tmp_file2, 'w')
            f2.write(self.get_dtd())
            f2.close()
            f = open(tmp_file, 'w')
            formatter = XMLFormatter()
            formatter.configure({'name': 'xmlformatter', 'parent': _Parent()})
            stream = formatter.format(self.data)
            output = ''
            data = stream.read(1024)
            while data:
                output += data
                data = stream.read(1024)
            f.write(output)
            f.close()
            command = 'xmllint -dtdvalid ' + str(tmp_file2) + ' ' + str(
                tmp_file)
            stdin, stdout, stderr = os.popen3(command)
            out = stdout.readlines()
            err = stderr.readlines()
            if err:
                error = ''
                for e in err:
                    error += e + '\n'

                self.fail('File does not conform to the DTD:\n' + error)
        finally:
            if tmp_file:
                try:
                    os.unlink(tmp_file)
                except:
                    pass
            if tmp_file2:
                try:
                    os.unlink(tmp_file2)
                except:
                    pass
Exemplo n.º 6
0
 def test_DTD_1(self):
     try:
         tmp_file = None
         tmp_file = self.temp_file_name()
         tmp_file2 = self.temp_file_name()
         f2 = open(tmp_file2,'w')
         f2.write(self.get_dtd())
         f2.close()
         f = open(tmp_file,'w')
         formatter = XMLFormatter()
         formatter.configure({'name':'xmlformatter','parent':_Parent()})
         stream = formatter.format(self.data)
         output = ''
         data = stream.read(1024)
         while data:
             output += data
             data = stream.read(1024)
         f.write(output)
         f.close()
         command = 'xmllint -dtdvalid ' + str(tmp_file2) + ' ' + str(tmp_file)
         stdin, stdout,stderr = os.popen3(command)
         out  = stdout.readlines()
         err = stderr.readlines()
         if err:
             error = ''
             for e in err:
                 error += e + '\n'
                 
             self.fail('File does not conform to the DTD:\n' + error)
     finally:
         if tmp_file:
             try:
                 os.unlink(tmp_file)
             except:
                 pass
         if tmp_file2:
             try:
                 os.unlink(tmp_file2)
             except:
                 pass