def testWsdlAutoObj(self): """Test whether the wsdl_auto_obj script properly parses the test WSDL.""" def MockWsdlInfoToUrl (wsdl_info, service): """Mock WSDL to URL function, which always points to the mock WSDL.""" return 'file:%s' % os.path.join(self.__class__.DATA_LOCATION, self.__class__.WSDL_NAME) try: wsdl_auto_obj.main(self.__class__.DATA_LOCATION, self.__class__.TYPES_FILENAME, self.__class__.OPS_FILENAME, self.__class__.API_TARGETS, MockWsdlInfoToUrl) types_map = pickle.load(open(os.path.join( self.__class__.DATA_LOCATION, self.__class__.TYPES_FILENAME), 'r')) operations_map = pickle.load(open(os.path.join( self.__class__.DATA_LOCATION, self.__class__.OPS_FILENAME), 'r')) self.assertTrue(types_map == self.__class__.CANONICAL_TYPES_MAP) self.assertTrue(operations_map == self.__class__.CANONICAL_OPERATIONS_MAP) finally: for filename in (self.__class__.TYPES_FILENAME, self.__class__.OPS_FILENAME): if os.path.exists(os.path.join(self.__class__.DATA_LOCATION, filename)): os.unlink(os.path.join(self.__class__.DATA_LOCATION, filename))
data = Utils.ReadFile(f_path) for type in re.compile('class (\w+)_Def\(').findall(data): if type.endswith('Error') and type not in error_types: if type not in old_error_types: print ' [+] found new error type, %s' % type error_types.append(type) # Write error types to a CSV file. data = ['Type'] for type in sorted(set(error_types)): data.append('%s' % type) data.append('') f_path = os.path.abspath(os.path.join(LIB_HOME, 'data', 'error_types.csv')) fh = open(f_path, 'w') try: fh.write('\n'.join(data)) finally: fh.close() # Generate WSDL definitions pickle. print 'Generating WSDL definition pickles...' pickle_location = os.path.join('..', '..', '..', 'adspygoogle', 'adwords', 'data') types_filename = 'wsdl_type_defs.pkl' operation_filename = 'wsdl_ops_defs.pkl' wsdl_auto_obj.main(pickle_location, types_filename, operation_filename, API_TARGETS, AdWordsWsdlToUrl) print '... done.'