Skip to content

Commit afe647c

Browse files
committed
Merge pull request AuthorizeNet#15 from krgupta1/master
modifications to static function and writing error to stderr
2 parents 4a2d406 + c570208 commit afe647c

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

authorizenet/utility.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@
66

77
from ConfigParser import SafeConfigParser
88
from ConfigParser import NoSectionError
9-
'''import ConfigParser'''
109
import os
11-
'''import logging'''
12-
#from authorizenet.constants import constants
10+
import sys
11+
#from __future__ import print_function
1312

1413
class helper():
1514
__parser = "null"
1615
__propertyfilename = "null"
17-
1816
__initialized = False
1917

2018
@staticmethod
@@ -40,20 +38,28 @@ def __classinitialized():
4038
@staticmethod
4139
def getproperty(propertyname):
4240
stringvalue = "null"
43-
temp = propertyname
41+
4442
if ('null' != helper.getpropertyfile()):
45-
helper.__parser = SafeConfigParser({"http":"","https":"","ftp":""})
43+
if (False == helper.__classinitialized()):
44+
if ('null' == helper.getparser()):
45+
try:
46+
helper.__parser = SafeConfigParser({"http":"","https":"","ftp":""})
47+
except:
48+
print ("Parser could not be initialized")
49+
4650
if ('null' != helper.getparser()):
4751
try:
48-
if ( False == helper.__classinitialized()):
49-
helper.getparser().read(helper.__propertyfilename)
50-
__initialized = True
52+
helper.getparser().read(helper.__propertyfilename)
53+
helper.__initialized = True
5154
except:
52-
print ("helper class not initialized")
53-
if (__initialized == True):
54-
print (" Reading %s from property file %s" % (propertyname, helper.__propertyfilename))
55-
stringvalue = helper.getparser().get("properties", propertyname)
55+
print ("Unable to load the property file")
56+
57+
if (True == helper.__classinitialized()):
58+
try:
59+
stringvalue = helper.getparser().get("properties", propertyname)
60+
except:
61+
sys.stderr.write("%s not found" %propertyname )
5662

5763
if ( "null" == stringvalue):
58-
stringvalue = os.getenv(temp)
64+
stringvalue = os.getenv(propertyname)
5965
return stringvalue

tests/testssample.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'''
2-
Created on Jul 13, 2015
2+
Created on Nov 16, 2015
33
44
@author: krgupta
55
'''
@@ -19,9 +19,17 @@
1919
from tests import apitestbase
2020
from authorizenet.apicontrollers import *
2121
import test
22+
from authorizenet import utility
23+
24+
class test_ReadProperty(apitestbase.ApiTestBase):
25+
def testPropertyFromFile(self):
26+
login= utility.helper.getproperty("api_login_id")
27+
transactionkey = utility.helper.getproperty("transaction_key")
28+
self.assertIsNotNone(login)
29+
self.assertIsNotNone(transactionkey)
2230

2331
class test_TransactionReportingUnitTest(apitestbase.ApiTestBase):
24-
32+
'''
2533
def testGetTransactionDetails(self):
2634
2735
gettransactiondetailsrequest = apicontractsv1.getTransactionDetailsRequest()
@@ -31,7 +39,7 @@ def testGetTransactionDetails(self):
3139
gettransactiondetailscontroller.execute()
3240
response = gettransactiondetailscontroller.getresponse()
3341
self.assertEquals('Ok', response.messages.resultCode)
34-
42+
'''
3543
class test_RecurringBillingTest(apitestbase.ApiTestBase):
3644

3745
def testCreateSubscription(self):
@@ -45,7 +53,7 @@ def testCreateSubscription(self):
4553
response = arbcreatesubscriptioncontroller.getresponse()
4654
self.assertIsNotNone(response.subscriptionId)
4755
self.assertEquals('Ok', response.messages.resultCode)
48-
56+
'''
4957
def testcancelSubscription(self):
5058
5159
cancelsubscriptionrequest = apicontractsv1.ARBCancelSubscriptionRequest()
@@ -56,7 +64,7 @@ def testcancelSubscription(self):
5664
cancelsubscriptioncontroller.execute()
5765
response = cancelsubscriptioncontroller.getresponse()
5866
self.assertEquals('Ok', response.messages.resultCode)
59-
67+
'''
6068
class paymentTransactionUnitTest(apitestbase.ApiTestBase):
6169

6270
def testauthCaputureTransaction(self):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy