Skip to content

Commit

Permalink
Merge pull request #15 from krgupta1/master
Browse files Browse the repository at this point in the history
modifications to static function and writing error to stderr
  • Loading branch information
brianmc committed Nov 17, 2015
2 parents 4a2d406 + c570208 commit afe647c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
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

0 comments on commit afe647c

Please sign in to comment.