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_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 #4
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')
Beispiel #5
0
 def test_start_transaction(self):
     pagarme = Pagarme(self.api_key)
     transaction = pagarme.start_transaction(amount=314,
                                             card_hash='hashcard')
     self.assertIsInstance(transaction, Transaction)
Beispiel #6
0
 def test_invalid_api(self):
     with self.assertRaises(ValueError):
         pagarme = Pagarme('')
Beispiel #7
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 #8
0
 def test_validade_figerprint(self):
     pagarme = Pagarme(self.api_key)
     self.assertTrue(
         pagarme.validate_fingerprint(
             1, '7eaf1eae64ab8d91bcd2c315350a7e9b321808ee'))
Beispiel #9
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)
Beispiel #10
0
 def test_find_all_subscriptions(self):
     pagarme = Pagarme(self.api_key)
     plans = pagarme.all_subscriptions()
     self.assertIsInstance(plans, list)
Beispiel #11
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 #12
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 #13
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 #14
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)
Beispiel #15
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)
Beispiel #16
0
 def test_find_all_subscriptions_error(self):
     pagarme = Pagarme(self.api_key)
     with self.assertRaises(PagarmeApiError):
         pagarme.all_subscriptions()
Beispiel #17
0
 def test_find_transaction_by_id(self):
     pagarme = Pagarme(self.api_key)
     transaction = pagarme.find_transaction_by_id(314)
     self.assertIsInstance(transaction, Transaction)
Beispiel #18
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 #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)
Beispiel #20
0
 def test_can_instantiate(self):
     pagarme = Pagarme(self.api_key)
     self.assertIsInstance(pagarme, CorrectlyPagarme)
Beispiel #21
0
 def test_validate_request_signature(self):
     pagarme = Pagarme(self.api_key)
     self.assertTrue(
         pagarme.validate_request_signature(
             'sampledata=123512536&another=test',
             'sha1=9496eceeb457c5fe5fdb88aafb0d60ee9f96887d'))
Beispiel #22
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')