Skip to content

Removed all print statements. #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ createtransactioncontroller.execute()
response = createtransactioncontroller.getresponse()

if (response.messages.resultCode=="Ok"):
print "Transaction ID : %s" % response.transactionResponse.transId
print("Transaction ID : {}".format(response.transactionResponse.transId))
else:
print "response code: %s" % response.messages.resultCode
print("Response code: {}".format(response.messages.resultCode))

````
### Setting Production or Sandbox Environments
Expand Down
4 changes: 2 additions & 2 deletions authorizenet/apicontrollersbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,14 @@ def execute(self):
#if type(self.getresponseclass()) == type(self._response):
if type(self.getresponseclass()) != type(self._mainObject):
if self._response.messages.resultCode == "Error":
print "Response error"
logging.debug("Response error")
domResponse = xml.dom.minidom.parseString(self._httpResponse)
logging.debug('Received response: %s' % domResponse.toprettyxml())
else:
#Need to handle ErrorResponse
logging.debug('Error retrieving response for request: %s' % self._request)
else:
print "Did not receive http response"
logging.debug("Did not receive http response")
return

def getresponse(self):
Expand Down
11 changes: 7 additions & 4 deletions authorizenet/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

from ConfigParser import SafeConfigParser
from ConfigParser import NoSectionError
import logging
import os
import sys
#from __future__ import print_function

logger = logging.getLogger(__name__)


class helper():
__parser = "null"
Expand Down Expand Up @@ -45,20 +48,20 @@ def getproperty(propertyname):
try:
helper.__parser = SafeConfigParser({"http":"","https":"","ftp":""})
except:
print ("Parser could not be initialized")
logger.debug("Parser could not be initialized")

if ('null' != helper.getparser()):
try:
helper.getparser().read(helper.__propertyfilename)
helper.__initialized = True
except:
print ("Unable to load the property file")
logger.debug("Unable to load the property file")

if (True == helper.__classinitialized()):
try:
stringvalue = helper.getparser().get("properties", propertyname)
except:
sys.stderr.write("'%s' not found\n" %propertyname )
logger.exception("'{}' not found".format(propertyname))

if ( "null" == stringvalue):
stringvalue = os.getenv(propertyname)
Expand Down
36 changes: 5 additions & 31 deletions tests/testpyxb.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ def __PyxbDeserialization(self, lastElement = None):
try:
xmlRequest = createtransactionrequest.toxml(encoding=constants.xml_encoding, element_name='createTransactionRequest')
xmlRequest = xmlRequest.replace(constants.nsNamespace1, '')
xmlRequest = xmlRequest.replace(constants.nsNamespace2, '')
##print ("xmlRequest %s " %xmlRequest)
xmlRequest = xmlRequest.replace(constants.nsNamespace2, '')
logging.debug( "Xml Request: %s" % xmlRequest)
except Exception as ex:
logging.debug( "Xml Exception: %s" % ex)
Expand All @@ -72,17 +71,14 @@ def __PyxbDeserialization(self, lastElement = None):
self.assertIsNotNone(deserializedObject, "Null deserializedObject ")

if type(createtransactionrequest) == type(deserializedObject):
##print (" for good xml objects are equal")
logging.debug( "createtransactionrequest object is equal to deserializedObject")
else:
##print ("for good xml some error: objects are NOT equal" )
logging.debug( "createtransactionrequest object is NOT equal to deserializedObject")

deseriaziedObjectXmlRequest = deserializedObject.toxml(encoding=constants.xml_encoding, element_name='deserializedObject')
deseriaziedObjectXmlRequest = deseriaziedObjectXmlRequest.replace(constants.nsNamespace1, '')
deseriaziedObjectXmlRequest = deseriaziedObjectXmlRequest.replace(constants.nsNamespace2, '')
logging.debug( "Good Dom Request: %s " % deseriaziedObjectXmlRequest )
##print ( "Good De-serialized XML: %s \n" % deseriaziedObjectXmlRequest )
except Exception as ex:
logging.error( 'Create Document Exception: %s, %s', type(ex), ex.args )
else:
Expand All @@ -93,9 +89,7 @@ def __PyxbDeserialization(self, lastElement = None):
badXmlElement = "<badElement>BadElement</badElement>"
badXmlRequest = lines[0] + badXmlElement + splitString + lines[1]
logging.debug( "Bad XmlRequest: %s" % badXmlRequest)
##print ("ElementInMidXML Request: %s \n" %badXmlRequest)
except Exception as ex:
##print ("ElementInMidXML can not be inserted: %s, %s",type(ex), ex.args)
logging.debug( "ElementInMidXML can not be inserted: %s, %s" ,type(ex), ex.args)
if (lastElement == True):
try:
Expand All @@ -104,9 +98,7 @@ def __PyxbDeserialization(self, lastElement = None):
badXmlElementAtLast = "<badElementAtLast>BadElementAtLast</badElementAtLast>"
badXmlRequest = lines[0] + badXmlElementAtLast + splitStringAtLast + lines[1]
logging.debug( "Bad XmlRequest at Last: %s" % badXmlRequest)
##print ("ElementAtLastXML Request: %s \n" %badXmlRequest)
except Exception as ex:
##print ("ElementAtLastXML can not be inserted: %s, %s",type(ex), ex.args)
logging.debug("ElementAtLastXML can not be inserted: %s, %s",type(ex), ex.args)
try:
deserializedBadObject = apicontractsv1.CreateFromDocument(badXmlRequest)
Expand All @@ -115,11 +107,10 @@ def __PyxbDeserialization(self, lastElement = None):
badDomXml = badDomXml.replace(constants.nsNamespace1, '')
badDomXml = badDomXml.replace(constants.nsNamespace2, '')
logging.debug( "Bad Dom Request: %s " % badDomXml )
##print ("Bad Dom De-serialized: %s \n" %badDomXml)
except Exception as ex:
logging.error( 'Create Document Exception: %s, %s', type(ex), ex.args )
##print ("Exception while de-serializing bad dom: %s, %s",type(ex), ex.args)


class test_CustomerProfile(unittest.TestCase):
def testGetCustomerProfile(self):
loggingfilename = utility.helper.getproperty(constants.propertiesloggingfilename)
Expand All @@ -144,7 +135,6 @@ def testGetCustomerProfile(self):
xmlRequest = xmlRequest.replace(constants.nsNamespace1, '')
xmlRequest = xmlRequest.replace(constants.nsNamespace2, '')
logging.debug( "Xml Request: %s" % xmlRequest)
#print( "Xml Request: %s" % xmlRequest)
except Exception as ex:
logging.debug( "Xml Exception: %s" % ex)

Expand All @@ -155,29 +145,23 @@ def testGetCustomerProfile(self):
self.assertIsNotNone(deserializedObject, "Null deserializedObject ")

if type(getCustomerProfileRequest) == type(deserializedObject):
#print ("objects are equal")
logging.debug( "createtransactionrequest object is equal to deserializedObject")
else:
#print ("some error: objects are NOT equal" )
logging.debug( "createtransactionrequest object is NOT equal to deserializedObject")

deseriaziedObjectXmlRequest = deserializedObject.toxml(encoding=constants.xml_encoding, element_name='deserializedObject')
deseriaziedObjectXmlRequest = deseriaziedObjectXmlRequest.replace(constants.nsNamespace1, '')
deseriaziedObjectXmlRequest = deseriaziedObjectXmlRequest.replace(constants.nsNamespace2, '')
logging.debug( "Good Dom Request: %s " % deseriaziedObjectXmlRequest )
#print( "Good Dom Request: %s " % deseriaziedObjectXmlRequest )
#print("de-serialized successfully. GOOD CASE COMPLETE \n ")
except Exception as ex:

logging.error( 'Create Document Exception: %s, %s', type(ex), ex.args )

self.assertEquals(type(getCustomerProfileRequest), type(deserializedObject), "deseriaziedObject does not match original object")

try:
#print("starting with element in mid")
newxml = '<?xml version="1.0" encoding="utf-8"?><getCustomerProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><merchantAuthentication><name>unknown</name><transactionKey>anon</transactionKey></merchantAuthentication><kriti>11Jan</kriti><customerProfileId>36152115</customerProfileId></getCustomerProfileRequest>'

#print ("newxml: %s" %newxml)

DEserializedNEWObject = apicontractsv1.CreateFromDocument(newxml)
self.assertIsNotNone(DEserializedNEWObject, "Null deserializedObject ")

Expand All @@ -186,29 +170,19 @@ def testGetCustomerProfile(self):
DEseriaziedNEWObjectXmlRequest = DEseriaziedNEWObjectXmlRequest.replace(constants.nsNamespace1, '')
DEseriaziedNEWObjectXmlRequest = DEseriaziedNEWObjectXmlRequest.replace(constants.nsNamespace2, '')
logging.debug( "Good Dom Request: %s " % DEseriaziedNEWObjectXmlRequest )
#print( " DEseriaziedNEWObjectXmlRequest Request: %s " % DEseriaziedNEWObjectXmlRequest )
#print("de-serialized successfully")
#print("FINISHED element in mid \n ")
except Exception as ex:
#print("DEseriaziedNEWObjectXmlRequest is NOT DESerialized")
logging.error( 'Create Document Exception: %s, %s', type(ex), ex.args )


try:
#print("starting with element at last")
newxmlATLAst = '<?xml version="1.0" encoding="utf-8"?><getCustomerProfileRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"><merchantAuthentication><name>unknown</name><transactionKey>anon</transactionKey></merchantAuthentication><customerProfileId>36152115</customerProfileId><gupta>11Jan</gupta></getCustomerProfileRequest>'
#print ("newxmlATLAst: %s" %newxmlATLAst)
DEserializedNEWObject = apicontractsv1.CreateFromDocument(newxmlATLAst)
self.assertIsNotNone(DEserializedNEWObject, "Null deserializedObject ")
DEseriaziedNEWObjectXmlRequest = DEserializedNEWObject.toxml(encoding=constants.xml_encoding, element_name='deserializedObject')
DEseriaziedNEWObjectXmlRequest = DEseriaziedNEWObjectXmlRequest.replace(constants.nsNamespace1, '')
DEseriaziedNEWObjectXmlRequest = DEseriaziedNEWObjectXmlRequest.replace(constants.nsNamespace2, '')
logging.debug( "Good Dom Request: %s " % DEseriaziedNEWObjectXmlRequest )
#print( " DEseriaziedNEWATLASTObjectXmlRequest Request: %s " % DEseriaziedNEWObjectXmlRequest )
#print("de-serialized successfully")
#print("Finished element at last \n " )
except Exception as ex:
#print("DEseriaziedNEWATLASTObjectXmlRequest is NOT DESerialized")
except Exception as ex:
logging.error( 'Create Document Exception: %s, %s', type(ex), ex.args )

if __name__ =='__main__':
Expand Down