Exemplo n.º 1
0
 def test_create_subscription(self):
     pagarme = Pagarme(self.api_key)
     sub = pagarme.start_subscription(
         plan_id=20112,
         card_hash='hashcardlong',
         customer=Customer(email='*****@*****.**'))
     sub.create()
Exemplo n.º 2
0
 def test_create_subscription_with_plan(self):
     pagarme = Pagarme(self.api_key)
     plan = pagarme.find_plan_by_id(20112)
     sub = pagarme.start_subscription(
         plan=plan,
         card_hash='hashcardlong',
         customer=Customer(email='*****@*****.**'))
     sub.create()
Exemplo n.º 3
0
 def test_call_start_transaction(self):
     Pagarme.api_key = 'api_key'
     transaction = Pagarme.start_transaction(amount=10,
                                             card_hash='ahsh',
                                             piranha='doida',
                                             mane='garrinha')
     self.assertIsInstance(transaction, Transaction)
Exemplo n.º 4
0
 def test_call_without_api_key(self):
     with self.assertRaises(ValueError):
         Pagarme.find_transaction_by_id(1321)
Exemplo n.º 5
0
 def test_find_all_subscriptions_error(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(PagarmeApiError):
         pagarme.all_subscriptions()
Exemplo n.º 6
0
 def test_find_subscription_by_id(self):
     pagarme = Pagarme(self.api_key)
     sub = pagarme.find_subscription_by_id(16892)
     self.assertEqual(16892, sub.data['id'])
Exemplo n.º 7
0
 def test_create_subscription(self):
     pagarme = Pagarme(self.api_key)
     sub = pagarme.start_subscription(plan_id=20112, card_hash='hashcardlong', customer=Customer(email='*****@*****.**'))
     sub.create()
Exemplo n.º 8
0
 def test_create_plan_without_days(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         pagarme.start_plan(name='Test Plan', days=30)
Exemplo n.º 9
0
 def test_create_plan(self):
     pagarme = Pagarme(self.api_key)
     plan = pagarme.start_plan(name='Test Plan', amount=314, days=30)
     plan.create()
     self.assertEqual(20112, plan.data['id'])
Exemplo n.º 10
0
 def test_find_transaction_by_id(self):
     pagarme = Pagarme(self.api_key)
     transaction = pagarme.find_transaction_by_id(314)
     self.assertIsInstance(transaction, Transaction)
Exemplo n.º 11
0
 def test_find_all_subscriptions(self):
     pagarme = Pagarme(self.api_key)
     plans = pagarme.all_subscriptions()
     self.assertIsInstance(plans, list)
Exemplo n.º 12
0
 def test_find_subscription_by_id(self):
     pagarme = Pagarme(self.api_key)
     sub = pagarme.find_subscription_by_id(16892)
     self.assertEqual(16892, sub.data['id'])
Exemplo n.º 13
0
 def test_find_plan_by_id(self):
     pagarme = Pagarme(self.api_key)
     plan = pagarme.find_plan_by_id(20112)
     self.assertEqual(20112, plan.data['id'])
Exemplo n.º 14
0
 def test_create_plan_without_days(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         pagarme.start_plan(name='Test Plan', days=30)
Exemplo n.º 15
0
 def test_create_plan_without_amount(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         pagarme.start_plan(name='Test Plan', amount=314)
Exemplo n.º 16
0
 def test_start_transaction(self):
     pagarme = Pagarme(self.api_key)
     transaction = pagarme.start_transaction(amount=314, card_hash='hashcard')
     self.assertIsInstance(transaction, Transaction)
Exemplo n.º 17
0
 def test_start_transaction_invalid_payment_method(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         transaction = pagarme.start_transaction(amount=314, card_hash='hashcard', payment_method='rice_bag')
Exemplo n.º 18
0
 def test_find_all_subscriptions_error(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(PagarmeApiError):
         pagarme.all_subscriptions()
Exemplo n.º 19
0
 def test_get_all_transaction_fails(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(PagarmeApiError):
         transactions = pagarme.all_transactions(page=2,count=3)
Exemplo n.º 20
0
 def test_find_card_by_id(self):
     pagarme = Pagarme(self.api_key)
     card = pagarme.find_card_by_id('card_ci6y37h16wrxsmzyi')
     self.assertEqual('card_ci6y37h16wrxsmzyi', card.id)
Exemplo n.º 21
0
 def test_create_plan(self):
     pagarme = Pagarme(self.api_key)
     plan = pagarme.start_plan(name='Test Plan', amount=314, days=30)
     plan.create()
     self.assertEqual(20112, plan.data['id'])
Exemplo n.º 22
0
 def test_call_without_api_key(self):
     with self.assertRaises(ValueError):
         Pagarme.find_transaction_by_id(1321)
Exemplo n.º 23
0
 def test_find_plan_by_id(self):
     pagarme = Pagarme(self.api_key)
     plan = pagarme.find_plan_by_id(20112)
     self.assertEqual(20112, plan.data['id'])
Exemplo n.º 24
0
 def test_start_transaction(self):
     pagarme = Pagarme(self.api_key)
     transaction = pagarme.start_transaction(amount=314,
                                             card_hash='hashcard')
     self.assertIsInstance(transaction, Transaction)
Exemplo n.º 25
0
 def test_create_subscription_with_plan(self):
     pagarme = Pagarme(self.api_key)
     plan = pagarme.find_plan_by_id(20112)
     sub = pagarme.start_subscription(plan=plan, card_hash='hashcardlong', customer=Customer(email='*****@*****.**'))
     sub.create()
Exemplo n.º 26
0
 def test_start_transaction_invalid_amount(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         transaction = pagarme.start_transaction(amount=None,
                                                 card_hash='hashcard')
Exemplo n.º 27
0
 def test_find_all_subscriptions(self):
     pagarme = Pagarme(self.api_key)
     plans = pagarme.all_subscriptions()
     self.assertIsInstance(plans, list)
Exemplo n.º 28
0
 def test_start_transaction_invalid_payment_method(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         transaction = pagarme.start_transaction(amount=314,
                                                 card_hash='hashcard',
                                                 payment_method='rice_bag')
Exemplo n.º 29
0
 def test_find_card_by_id(self):
     pagarme = Pagarme(self.api_key)
     card = pagarme.find_card_by_id('card_ci6y37h16wrxsmzyi')
     self.assertEqual('card_ci6y37h16wrxsmzyi', card.id)
Exemplo n.º 30
0
 def test_start_transaction_invalid_installments(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         transaction = pagarme.start_transaction(amount=314,
                                                 card_hash='hashcard',
                                                 installments=0)
Exemplo n.º 31
0
 def test_call_start_transaction(self):
     Pagarme.api_key = 'api_key'
     transaction = Pagarme.start_transaction(amount=10, card_hash='ahsh', piranha='doida', mane='garrinha')
     self.assertIsInstance(transaction, Transaction)
Exemplo n.º 32
0
 def test_find_transaction_by_id(self):
     pagarme = Pagarme(self.api_key)
     transaction = pagarme.find_transaction_by_id(314)
     self.assertIsInstance(transaction, Transaction)
Exemplo n.º 33
0
 def test_start_transaction_invalid_amount(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         transaction = pagarme.start_transaction(amount=None, card_hash='hashcard')
Exemplo n.º 34
0
 def test_get_all_transaction(self):
     pagarme = Pagarme(self.api_key)
     transactions = pagarme.all_transactions(page=2, count=3)
     self.assertTrue(len(transactions) == 1)
Exemplo n.º 35
0
 def test_start_transaction_invalid_installments(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         transaction = pagarme.start_transaction(amount=314, card_hash='hashcard', installments=0)
Exemplo n.º 36
0
 def test_get_all_transaction_fails(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(PagarmeApiError):
         transactions = pagarme.all_transactions(page=2, count=3)
Exemplo n.º 37
0
 def test_get_all_transaction(self):
     pagarme = Pagarme(self.api_key)
     transactions = pagarme.all_transactions(page=2,count=3)
     self.assertTrue(len(transactions) == 1)
Exemplo n.º 38
0
 def test_validade_figerprint(self):
     pagarme = Pagarme(self.api_key)
     self.assertTrue(
         pagarme.validate_fingerprint(
             1, '7eaf1eae64ab8d91bcd2c315350a7e9b321808ee'))
Exemplo n.º 39
0
 def test_validade_figerprint(self):
     pagarme = Pagarme(self.api_key)
     self.assertTrue(pagarme.validate_fingerprint(1, '7eaf1eae64ab8d91bcd2c315350a7e9b321808ee'))
Exemplo n.º 40
0
 def test_validate_request_signature(self):
     pagarme = Pagarme(self.api_key)
     self.assertTrue(
         pagarme.validate_request_signature(
             'sampledata=123512536&another=test',
             'sha1=9496eceeb457c5fe5fdb88aafb0d60ee9f96887d'))
Exemplo n.º 41
0
 def test_create_plan_without_amount(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         pagarme.start_plan(name='Test Plan', amount=314)
Exemplo n.º 42
0
 def test_validate_request_signature_with_wrong_hash(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(NotImplementedError):
         pagarme.validate_request_signature(
             'sampledata=123512536&another=test',
             'md5=9496eceeb457c5fe5fdb88aafb0d60ee9f96887d')