Conditions | 3 |
Total Lines | 65 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | ''' |
||
25 | def setUp(self): |
||
26 | utility.helper.setpropertyfile('anet_python_sdk_properties.ini') |
||
27 | |||
28 | self.amount = str(round(random.random()*100, 2)) |
||
29 | |||
30 | self.merchantAuthentication = apicontractsv1.merchantAuthenticationType() |
||
31 | |||
32 | self.merchantAuthentication.name = utility.helper.getproperty('api.login.id') |
||
33 | if self.merchantAuthentication.name == None: |
||
34 | self.merchantAuthentication.name = utility.helper.getproperty('api_login_id') |
||
35 | |||
36 | self.merchantAuthentication.transactionKey = utility.helper.getproperty('transaction.key') |
||
37 | if self.merchantAuthentication.transactionKey == None: |
||
38 | self.merchantAuthentication.transactionKey = utility.helper.getproperty('transaction_key') |
||
39 | |||
40 | self.ref_id = 'Sample' |
||
41 | |||
42 | self.dateOne = datetime.date(2020, 8, 30) |
||
43 | # self.interval = CTD_ANON() |
||
44 | # self.interval.length = 1 |
||
45 | # self.interval.unit = 'months' |
||
46 | self.paymentScheduleOne = apicontractsv1.paymentScheduleType() |
||
47 | self.paymentScheduleOne.interval = apicontractsv1.paymentScheduleTypeInterval() |
||
48 | |||
49 | self.paymentScheduleOne.interval.length = 1 |
||
50 | self.paymentScheduleOne.interval.unit = 'months' |
||
51 | |||
52 | self.paymentScheduleOne.startDate = self.dateOne |
||
53 | self.paymentScheduleOne.totalOccurrences = 12 |
||
54 | self.paymentScheduleOne.trialOccurrences = 1 |
||
55 | |||
56 | self.creditCardOne = apicontractsv1.creditCardType() |
||
57 | self.creditCardOne.cardNumber = "4111111111111111" |
||
58 | self.creditCardOne.expirationDate = "2020-12" |
||
59 | |||
60 | self.payment = apicontractsv1.paymentType() |
||
61 | self.payment.creditCard = self.creditCardOne |
||
62 | |||
63 | self.customerOne = apicontractsv1.nameAndAddressType() |
||
64 | self.customerOne.firstName = "John" + str(random.randint(0, 10000)) |
||
65 | self.customerOne.lastName = "Smith" |
||
66 | |||
67 | self.customerData = apicontractsv1.customerDataType() |
||
68 | self.customerData.id = "99999456654" |
||
69 | |||
70 | self.subscriptionOne = apicontractsv1.ARBSubscriptionType() |
||
71 | self.subscriptionOne.paymentSchedule = self.paymentScheduleOne |
||
72 | self.subscriptionOne.amount = Decimal(str(round(random.random()*100, 2))) |
||
73 | self.subscriptionOne.trialAmount = Decimal(str(round(random.random()*100, 2))) |
||
74 | self.subscriptionOne.payment = self.payment |
||
75 | self.subscriptionOne.billTo = self.customerOne |
||
76 | |||
77 | self.order = apicontractsv1.orderType() |
||
78 | self.order.invoiceNumber = "INV-21345" |
||
79 | self.order.description = "Product description" |
||
80 | |||
81 | self.billTo = apicontractsv1.customerAddressType() |
||
82 | self.billTo.firstName = "Ellen" |
||
83 | self.billTo.lastName = "Johnson" |
||
84 | self.billTo.company = "Souveniropolis" |
||
85 | self.billTo.address = "14 Main St" |
||
86 | self.billTo.city = "Seattle" |
||
87 | self.billTo.state = "WA" |
||
88 | self.billTo.zip = "98122" |
||
89 | self.billTo.country = "USA" |
||
90 | |||
93 |