Skip to content

modifications to static function and writing error to stderr #15

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

Merged
merged 1 commit into from
Nov 17, 2015
Merged
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
34 changes: 20 additions & 14 deletions authorizenet/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@

from ConfigParser import SafeConfigParser
from ConfigParser import NoSectionError
'''import ConfigParser'''
import os
'''import logging'''
#from authorizenet.constants import constants
import sys
#from __future__ import print_function

class helper():
__parser = "null"
__propertyfilename = "null"

__initialized = False

@staticmethod
Expand All @@ -40,20 +38,28 @@ def __classinitialized():
@staticmethod
def getproperty(propertyname):
stringvalue = "null"
temp = propertyname

if ('null' != helper.getpropertyfile()):
helper.__parser = SafeConfigParser({"http":"","https":"","ftp":""})
if (False == helper.__classinitialized()):
if ('null' == helper.getparser()):
try:
helper.__parser = SafeConfigParser({"http":"","https":"","ftp":""})
except:
print ("Parser could not be initialized")

if ('null' != helper.getparser()):
try:
if ( False == helper.__classinitialized()):
helper.getparser().read(helper.__propertyfilename)
__initialized = True
helper.getparser().read(helper.__propertyfilename)
helper.__initialized = True
except:
print ("helper class not initialized")
if (__initialized == True):
print (" Reading %s from property file %s" % (propertyname, helper.__propertyfilename))
stringvalue = helper.getparser().get("properties", propertyname)
print ("Unable to load the property file")

if (True == helper.__classinitialized()):
try:
stringvalue = helper.getparser().get("properties", propertyname)
except:
sys.stderr.write("%s not found" %propertyname )

if ( "null" == stringvalue):
stringvalue = os.getenv(temp)
stringvalue = os.getenv(propertyname)
return stringvalue
18 changes: 13 additions & 5 deletions tests/testssample.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'''
Created on Jul 13, 2015
Created on Nov 16, 2015

@author: krgupta
'''
Expand All @@ -19,9 +19,17 @@
from tests import apitestbase
from authorizenet.apicontrollers import *
import test
from authorizenet import utility

class test_ReadProperty(apitestbase.ApiTestBase):
def testPropertyFromFile(self):
login= utility.helper.getproperty("api_login_id")
transactionkey = utility.helper.getproperty("transaction_key")
self.assertIsNotNone(login)
self.assertIsNotNone(transactionkey)

class test_TransactionReportingUnitTest(apitestbase.ApiTestBase):

'''
def testGetTransactionDetails(self):

gettransactiondetailsrequest = apicontractsv1.getTransactionDetailsRequest()
Expand All @@ -31,7 +39,7 @@ def testGetTransactionDetails(self):
gettransactiondetailscontroller.execute()
response = gettransactiondetailscontroller.getresponse()
self.assertEquals('Ok', response.messages.resultCode)
'''
class test_RecurringBillingTest(apitestbase.ApiTestBase):

def testCreateSubscription(self):
Expand All @@ -45,7 +53,7 @@ def testCreateSubscription(self):
response = arbcreatesubscriptioncontroller.getresponse()
self.assertIsNotNone(response.subscriptionId)
self.assertEquals('Ok', response.messages.resultCode)

'''
def testcancelSubscription(self):

cancelsubscriptionrequest = apicontractsv1.ARBCancelSubscriptionRequest()
Expand All @@ -56,7 +64,7 @@ def testcancelSubscription(self):
cancelsubscriptioncontroller.execute()
response = cancelsubscriptioncontroller.getresponse()
self.assertEquals('Ok', response.messages.resultCode)
'''
class paymentTransactionUnitTest(apitestbase.ApiTestBase):

def testauthCaputureTransaction(self):
Expand Down