Class: Test
- Inherits:
-
Minitest::Test
- Object
- Minitest::Test
- Test
- Defined in:
- lib/Test.rb
Class Method Summary collapse
Instance Method Summary collapse
- #setup ⇒ Object
- #test_cards ⇒ Object
- #test_customers ⇒ Object
- #test_orders ⇒ Object
- #test_payments ⇒ Object
- #test_refund ⇒ Object
- #test_wallets ⇒ Object
Class Method Details
.delete_all_cards ⇒ Object
59 60 61 62 63 64 |
# File 'lib/Test.rb', line 59 def self.delete_all_cards card_list = Cards.list(:customer_id=>'user') card_list.each do |card| Cards.delete(:card_token=>card.token) end end |
Instance Method Details
#setup ⇒ Object
24 25 26 |
# File 'lib/Test.rb', line 24 def setup = Time.now.to_i end |
#test_cards ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/Test.rb', line 66 def test_cards # Test for add card = Cards.create(merchant_id:'shreyas', customer_id:'user', customer_email:'[email protected]', card_number:*(10**6), card_exp_year:'20', card_exp_month:'12') refute_nil(card.reference) refute_nil(card.token) refute_nil(card.fingerprint) #pp card # Test for delete deleted_card = Cards.delete(card_token:card.token) assert(true,deleted_card.deleted) #pp deleted_card # Test for list #Test.delete_all_cards Cards.create(merchant_id:'shreyas', customer_id:'user', customer_email:'[email protected]', card_number: * (10 ** 6), card_exp_year:'20', card_exp_month:'12') Cards.create(merchant_id:'shreyas', customer_id:'user', customer_email:'[email protected]', card_number: * (10 ** 6)+1, card_exp_year:'20', card_exp_month:'12') card_list = Cards.list(customer_id:'user') refute_nil(card_list) assert_equal(card_list.length, 2) #pp card_list Test.delete_all_cards end |
#test_customers ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/Test.rb', line 127 def test_customers #Add customer customer = Customers.create( object_reference_id: "CustId#{@timestamp}", mobile_number: '7272727272', email_address: '[email protected]', first_name: 'temp', last_name: 'kumar', mobile_country_code: '35' ) refute_nil(customer) #Get customer customer = Customers.get( customer_id: customer.id ) refute_nil(customer) #Update customer customer = Customers.update( customer_id: customer.id, mobile_number: '7272727273', email_address: '[email protected]', first_name: 'newtemp', last_name: 'newkumar', mobile_country_code: '91' ) refute_nil(customer) #List customer customer = Customers.list( count: 1 ) assert_equal(customer['count'], 1) end |
#test_orders ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/Test.rb', line 28 def test_orders # Test for create order = Orders.create(order_id:, amount:1000) assert_equal('CREATED', order.status) # Test for payment links refute_nil(order.payment_links) #pp order # Test for get_status status = Orders.status(order_id:) assert_equal(Float(status.order_id), ) #pp status # Test for list order_list = Orders.list refute_nil(order_list) #pp order_list # Test for update updated_order = Orders.update(order_id:, amount:500) status = Orders.status(order_id:) assert_equal(status.amount, updated_order.amount) end |
#test_payments ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/Test.rb', line 92 def test_payments # Test for create_card_payment payment = Payments.create_card_payment( order_id:1470043679, merchant_id:'azhar', redirect_after_payment:false, card_number:'4242424242424242', name_on_card:'Customer', card_exp_year:'20', card_exp_month:'12', card_security_code:'123', save_to_locker:false) refute_nil(payment.txn_id) assert_equal(payment.status, 'PENDING_VBV') # Test for create_net_banking_payment payment = Payments.create_net_banking_payment( order_id:1470043679, merchant_id:'azhar', payment_method:'NB_DUMMY', redirect_after_payment:false) refute_nil(payment.txn_id) assert_equal(payment.status, 'PENDING_VBV') # Test for create_wallet_payment payment = Payments.create_wallet_payment( order_id:'check5', merchant_id:'azharamin', payment_method:'MOBIKWIK', redirect_after_payment:false) refute_nil(payment.txn_id) assert_match(/^(PENDING_VBV|CHARGED)$/,payment.status) end |
#test_refund ⇒ Object
53 54 55 56 57 |
# File 'lib/Test.rb', line 53 def test_refund # Test for refund refunded_order = Orders.refund(unique_request_id: , order_id: '1471441349',amount: 1) #pp refunded_order end |
#test_wallets ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/Test.rb', line 163 def test_wallets # List wallets by orderId wallets = Wallets.list(order_id:'1471434419') refute_nil(wallets[0].id) # List wallets by customerId wallets = Wallets.list(customer_id:'guest_user_101') refute_nil(wallets[0].id) # List wallets by customerId wallets = Wallets.refresh_balance(customer_id:'guest_user_104') refute_nil(wallets[0].id) end |