| Conditions | 1 |
| Total Lines | 58 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 1 |
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 | ''' |
||
| 21 | def setUp(self): |
||
| 22 | utility.helper.setpropertyfile('anet_python_sdk_properties.ini') |
||
| 23 | |||
| 24 | self.amount = str(round(random.random()*100, 2)) |
||
| 25 | |||
| 26 | self.merchantAuthentication = apicontractsv1.merchantAuthenticationType() |
||
| 27 | self.merchantAuthentication.name = utility.helper.getproperty('api.login.id') |
||
| 28 | self.merchantAuthentication.transactionKey = utility.helper.getproperty('transaction.key') |
||
| 29 | self.ref_id = 'Sample' |
||
| 30 | |||
| 31 | self.dateOne = datetime.date(2020, 8, 30) |
||
| 32 | # self.interval = CTD_ANON() |
||
| 33 | # self.interval.length = 1 |
||
| 34 | # self.interval.unit = 'months' |
||
| 35 | self.paymentScheduleOne = apicontractsv1.paymentScheduleType() |
||
| 36 | self.paymentScheduleOne.interval = apicontractsv1.paymentScheduleTypeInterval() |
||
| 37 | |||
| 38 | self.paymentScheduleOne.interval.length = 1 |
||
| 39 | self.paymentScheduleOne.interval.unit = 'months' |
||
| 40 | |||
| 41 | self.paymentScheduleOne.startDate = self.dateOne |
||
| 42 | self.paymentScheduleOne.totalOccurrences = 12 |
||
| 43 | self.paymentScheduleOne.trialOccurrences = 1 |
||
| 44 | |||
| 45 | self.creditCardOne = apicontractsv1.creditCardType() |
||
| 46 | self.creditCardOne.cardNumber = "4111111111111111" |
||
| 47 | self.creditCardOne.expirationDate = "2020-12" |
||
| 48 | |||
| 49 | self.payment = apicontractsv1.paymentType() |
||
| 50 | self.payment.creditCard = self.creditCardOne |
||
| 51 | |||
| 52 | self.customerOne = apicontractsv1.nameAndAddressType() |
||
| 53 | self.customerOne.firstName = "John" |
||
| 54 | self.customerOne.lastName = "Smith" |
||
| 55 | |||
| 56 | self.customerData = apicontractsv1.customerDataType() |
||
| 57 | self.customerData.id = "99999456654" |
||
| 58 | |||
| 59 | self.subscriptionOne = apicontractsv1.ARBSubscriptionType() |
||
| 60 | self.subscriptionOne.paymentSchedule = self.paymentScheduleOne |
||
| 61 | self.subscriptionOne.amount = Decimal(str(round(random.random()*100, 2))) |
||
| 62 | self.subscriptionOne.trialAmount = Decimal ('0.03') |
||
| 63 | self.subscriptionOne.payment = self.payment |
||
| 64 | self.subscriptionOne.billTo = self.customerOne |
||
| 65 | |||
| 66 | self.order = apicontractsv1.orderType() |
||
| 67 | self.order.invoiceNumber = "INV-21345" |
||
| 68 | self.order.description = "Product description" |
||
| 69 | |||
| 70 | self.billTo = apicontractsv1.customerAddressType() |
||
| 71 | self.billTo.firstName = "Ellen" |
||
| 72 | self.billTo.lastName = "Johnson" |
||
| 73 | self.billTo.company = "Souveniropolis" |
||
| 74 | self.billTo.address = "14 Main St" |
||
| 75 | self.billTo.city = "Seattle" |
||
| 76 | self.billTo.state = "WA" |
||
| 77 | self.billTo.zip = "98122" |
||
| 78 | self.billTo.country = "USA" |
||
| 79 | |||
| 81 |