Beispiel #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()
Beispiel #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()
Beispiel #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)
 def test_call_without_api_key(self):
     with self.assertRaises(ValueError):
         Pagarme.find_transaction_by_id(1321)
 def test_find_all_subscriptions_error(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(PagarmeApiError):
         pagarme.all_subscriptions()
 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'])
 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()
 def test_create_plan_without_days(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         pagarme.start_plan(name='Test Plan', days=30)
 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'])
 def test_find_transaction_by_id(self):
     pagarme = Pagarme(self.api_key)
     transaction = pagarme.find_transaction_by_id(314)
     self.assertIsInstance(transaction, Transaction)
Beispiel #11
0
 def test_find_all_subscriptions(self):
     pagarme = Pagarme(self.api_key)
     plans = pagarme.all_subscriptions()
     self.assertIsInstance(plans, list)
Beispiel #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'])
Beispiel #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'])
Beispiel #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)
Beispiel #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)
 def test_start_transaction(self):
     pagarme = Pagarme(self.api_key)
     transaction = pagarme.start_transaction(amount=314, card_hash='hashcard')
     self.assertIsInstance(transaction, Transaction)
 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')
Beispiel #18
0
 def test_find_all_subscriptions_error(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(PagarmeApiError):
         pagarme.all_subscriptions()
 def test_get_all_transaction_fails(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(PagarmeApiError):
         transactions = pagarme.all_transactions(page=2,count=3)
Beispiel #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)
Beispiel #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'])
Beispiel #22
0
 def test_call_without_api_key(self):
     with self.assertRaises(ValueError):
         Pagarme.find_transaction_by_id(1321)
 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'])
Beispiel #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)
 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()
Beispiel #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')
 def test_find_all_subscriptions(self):
     pagarme = Pagarme(self.api_key)
     plans = pagarme.all_subscriptions()
     self.assertIsInstance(plans, list)
Beispiel #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')
 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)
Beispiel #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)
 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)
Beispiel #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)
 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')
Beispiel #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)
 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)
Beispiel #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)
 def test_get_all_transaction(self):
     pagarme = Pagarme(self.api_key)
     transactions = pagarme.all_transactions(page=2,count=3)
     self.assertTrue(len(transactions) == 1)
Beispiel #38
0
 def test_validade_figerprint(self):
     pagarme = Pagarme(self.api_key)
     self.assertTrue(
         pagarme.validate_fingerprint(
             1, '7eaf1eae64ab8d91bcd2c315350a7e9b321808ee'))
 def test_validade_figerprint(self):
     pagarme = Pagarme(self.api_key)
     self.assertTrue(pagarme.validate_fingerprint(1, '7eaf1eae64ab8d91bcd2c315350a7e9b321808ee'))
Beispiel #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'))
 def test_create_plan_without_amount(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(ValueError):
         pagarme.start_plan(name='Test Plan', amount=314)
Beispiel #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')