Example #1
0
    def _testXMLComparison(self, suffix="xml", response=None):
        """
        Helper function for the basic XML tree comparison to be used by
        `testXMLComparison`.
        """
        expected_path = os.path.join(self.getExpectedFileDir(),
                                     self.getExpectedFileName(suffix))
        response_path = os.path.join(self.getResponseFileDir(),
                                     self.getResponseFileName(suffix))

        # store the XML response
        if response is None:
            response = self.prepareXMLData(self.getXMLData())

        # check that the expected XML response exists
        if not os.path.isfile(expected_path):
            with open(response_path, 'w') as f:
                f.write(response)

            self.skipTest("Missing the expected XML response '%s'." %
                          expected_path)

        # perform the actual comparison
        try:
            xmlCompareFiles(expected_path, StringIO(response))
        except Exception as e:
            with open(response_path, 'w') as f:
                f.write(response)

            self.fail(
                "Response returned in '%s' is not equal to expected response "
                "in '%s'. REASON: %s " %
                (response_path, expected_path, str(e)))
Example #2
0
    def _testXMLComparison(self, suffix="xml", response=None):
        """
        Helper function for the basic XML tree comparison to be used by
        `testXMLComparison`.
        """
        expected_path_basename = os.path.join(self.getExpectedFileDir(),
                                              self.getExpectedFileName(suffix))
        response_path = os.path.join(self.getResponseFileDir(),
                                     self.getResponseFileName(suffix))

        expected_paths = glob.glob(expected_path_basename + '*')

        # store the XML response
        if response is None:
            response = self.prepareXMLData(self.getXMLData())

        # check that the expected XML response exists
        if not expected_paths:
            if isinstance(response, binary_type):
                response = response.decode()
            with open(response_path, 'w') as f:
                f.write(response)

            self.skipTest("Missing the expected XML response '%s'." %
                          expected_path_basename)

        fails = []
        for expected_path in expected_paths:
            # perform the actual comparison
            try:
                xmlCompareFiles(expected_path, BytesIO(response))
                break
            except Exception as e:
                fails.append(e)
        else:
            with open(response_path, 'w') as f:
                if isinstance(response, binary_type):
                    response = response.decode()
                f.write(response)
            reasons = ', '.join([str(e) for e in fails])
            self.fail("Response returned in '%s' is not equal to expected "
                      "response(s) in '%s'. REASON(S): %s " %
                      (response_path, ', '.join(expected_paths), reasons))
Example #3
0
 def _testXMLComparison( self , suffix = "xml" , response = None ): 
     """
     Helper function for the basic XML tree comparison to be used by `testXMLComparison`.
     """
     expected_path = os.path.join( self.getExpectedFileDir(), self.getExpectedFileName(suffix) )
     response_path = os.path.join( self.getResponseFileDir(), self.getResponseFileName(suffix) )
     
     # store the XML response 
     if response is None : response = self.getXMLData()
     
     # check that the expected XML response exists 
     if not os.path.isfile( expected_path ) : 
         with file(response_path, 'w') as fid : fid.write(response)
         self.skipTest( "Missing the expected XML response '%s'." % expected_path )
     
     # perform the actual comparison 
     try: 
         xmlCompareFiles( expected_path , StringIO(response) ) 
     except Exception as e : 
         with file(response_path, 'w') as fid : fid.write(response)
         self.fail( "Response returned in '%s' is not equal to expected response in '%s'. REASON: %s " % \
                 ( response_path , expected_path , str(e) ) )
Example #4
0
# THE SOFTWARE.
#-------------------------------------------------------------------------------
#

import sys
from eoxserver.testing import xcomp  # NOTE : make sure to set the right PYTHONPATH

#-------------------------------------------------------------------------------

if __name__ == "__main__":

    try:
        src0 = sys.argv[1]
        src1 = sys.argv[2]

        print "< FILE: %s" % src0
        print "> FILE: %s" % src1
    except:
        sys.stderr.write("ERROR: Not enough input arguments!\n")
        sys.stderr.write("USAGE: %s <xml-file> <xml-file> \n" % sys.argv[0])
        sys.exit(1)

    try:
        xcomp.xmlCompareFiles(src0, src1, True)
    except Exception as e:
        sys.stderr.write("ERROR: %s\n" % str(e))
        sys.exit(1)

    print " OK - XML files match. "
    sys.exit(0)
Example #5
0
# THE SOFTWARE.
#-------------------------------------------------------------------------------
#

import sys 
from eoxserver.testing import xcomp # NOTE : make sure to set the right PYTHONPATH 

#-------------------------------------------------------------------------------

if __name__ == "__main__" : 

    try :
        src0 = sys.argv[1] 
        src1 = sys.argv[2] 
        
        print "< FILE: %s" % src0
        print "> FILE: %s" % src1
    except :
        sys.stderr.write( "ERROR: Not enough input arguments!\n" ) 
        sys.stderr.write( "USAGE: %s <xml-file> <xml-file> \n" % sys.argv[0] ) 
        sys.exit(1)

    try : 
        xcomp.xmlCompareFiles( src0 , src1 , True ) 
    except Exception as e : 
        sys.stderr.write( "ERROR: %s\n" % str(e) ) 
        sys.exit(1)

    print " OK - XML files match. "
    sys.exit(0)