Conditions | 1 |
Total Lines | 54 |
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 = self.interval |
||
37 | self.paymentScheduleOne.startDate = self.dateOne |
||
38 | self.paymentScheduleOne.totalOccurrences = 12 |
||
39 | self.paymentScheduleOne.trialOccurrences = 1 |
||
40 | |||
41 | self.creditCardOne = apicontractsv1.creditCardType() |
||
42 | self.creditCardOne.cardNumber = "4111111111111111" |
||
43 | self.creditCardOne.expirationDate = "2020-12" |
||
44 | |||
45 | self.payment = apicontractsv1.paymentType() |
||
46 | self.payment.creditCard = self.creditCardOne |
||
47 | |||
48 | self.customerOne = apicontractsv1.nameAndAddressType() |
||
49 | self.customerOne.firstName = "John" |
||
50 | self.customerOne.lastName = "Smith" |
||
51 | |||
52 | self.customerData = apicontractsv1.customerDataType() |
||
53 | self.customerData.id = "99999456654" |
||
54 | |||
55 | self.subscriptionOne = apicontractsv1.ARBSubscriptionType() |
||
56 | self.subscriptionOne.paymentSchedule = self.paymentScheduleOne |
||
57 | self.subscriptionOne.amount = Decimal(str(round(random.random()*100, 2))) |
||
58 | self.subscriptionOne.trialAmount = Decimal ('0.03') |
||
59 | self.subscriptionOne.payment = self.payment |
||
60 | self.subscriptionOne.billTo = self.customerOne |
||
61 | |||
62 | self.order = apicontractsv1.orderType() |
||
63 | self.order.invoiceNumber = "INV-21345" |
||
64 | self.order.description = "Product description" |
||
65 | |||
66 | self.billTo = apicontractsv1.customerAddressType() |
||
67 | self.billTo.firstName = "Ellen" |
||
68 | self.billTo.lastName = "Johnson" |
||
69 | self.billTo.company = "Souveniropolis" |
||
70 | self.billTo.address = "14 Main St" |
||
71 | self.billTo.city = "Seattle" |
||
72 | self.billTo.state = "WA" |
||
73 | self.billTo.zip = "98122" |
||
74 | self.billTo.country = "USA" |
||
75 | |||
77 |