Beispiel #1
0
    def test_to_dict(self):
        customer = Customer(name='John Appleseed',
                            document_number='92545278157',
                            email='*****@*****.**',
                            address_street='Av. Brigadeiro Faria Lima',
                            address_neighborhood='Jardim Paulistano',
                            address_zipcode='01452000',
                            address_street_number='2941',
                            address_complementary='8º andar',
                            phone_ddd='11',
                            phone_number='30713261')

        data = customer.to_dict()
        self.assertEqual(data['customer[name]'], 'John Appleseed')
        self.assertEqual(data['customer[document_number]'], '92545278157')
        self.assertEqual(data['customer[email]'], '*****@*****.**')
        self.assertEqual(data['customer[address][street]'],
                         'Av. Brigadeiro Faria Lima')
        self.assertEqual(data['customer[address][neighborhood]'],
                         'Jardim Paulistano')
        self.assertEqual(data['customer[address][zipcode]'], '01452000')
        self.assertEqual(data['customer[address][street_number]'], '2941')
        self.assertEqual(data['customer[address][complementary]'], '8º andar')
        self.assertEqual(data['customer[phone][ddd]'], '11')
        self.assertEqual(data['customer[phone][number]'], '30713261')
Beispiel #2
0
 def test_metadata_is_sent(self):
     sub = Subscription(api_key='api_key',
         plan_id=20112,
         card_hash='longcardhash32432',
         customer=Customer(email='*****@*****.**'),
         metadata={'foo': 'bar'})
     self.assertEqual('bar', sub.get_data()['metadata[foo]'])
Beispiel #3
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 #4
0
 def test_can_create_error(self):
     sub = Subscription(api_key='api_key',
             plan_id=20112,
             card_hash='longcardhash32432',
             customer=Customer(email='*****@*****.**'))
     with self.assertRaises(PagarmeApiError):
         sub.create()
Beispiel #5
0
 def test_can_create_wiht_card_id(self):
     sub = Subscription(api_key='api_key',
             plan_id=20112,
             card_id='longcardid32432',
             customer=Customer(email='*****@*****.**'))
     sub.create()
     self.assertEqual(16892, sub.data['id'])
Beispiel #6
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()
    def test_to_dict(self):
        customer = Customer(
            name='John Appleseed',
            document_number='92545278157',
            email='*****@*****.**',
            address_street='Av. Brigadeiro Faria Lima',
            address_neighborhood='Jardim Paulistano',
            address_zipcode='01452000',
            address_street_number='2941',
            address_complementary='8º andar',
            phone_ddd='11',
            phone_number='30713261'
        )

        data = customer.to_dict()
        self.assertEqual(
            data['customer[name]'], 'John Appleseed'
        )
        self.assertEqual(
            data['customer[document_number]'], '92545278157'
        )
        self.assertEqual(
            data['customer[email]'], '*****@*****.**'
        )
        self.assertEqual(
            data['customer[address][street]'], 'Av. Brigadeiro Faria Lima'
        )
        self.assertEqual(
            data['customer[address][neighborhood]'], 'Jardim Paulistano'
        )
        self.assertEqual(
            data['customer[address][zipcode]'], '01452000'
        )
        self.assertEqual(
            data['customer[address][street_number]'], '2941'
        )
        self.assertEqual(
            data['customer[address][complementary]'], '8º andar'
        )
        self.assertEqual(
            data['customer[phone][ddd]'], '11'
        )
        self.assertEqual(
            data['customer[phone][number]'], '30713261'
        )
Beispiel #8
0
 def setUp(self):
     PagarMe.api_key = 'ak_test_key'
     self.customer = Customer(name='John Appleseed',
                              document_number='92545278157',
                              email='*****@*****.**',
                              address_street='Av. Brigadeiro Faria Lima',
                              address_neighborhood='Jardim Paulistano',
                              address_zipcode='01452000',
                              address_street_number='2941',
                              address_complementary='8º andar',
                              phone_ddd='11',
                              phone_number='30713261')
     self.metadata = MetaData(order_id='123456')
     self.api_endpoint = 'https://api.pagar.me/1/subscriptions'
Beispiel #9
0
 def test_subscription_without_invalid_plan_id(self):
     with self.assertRaises(ValueError):
         sub = Subscription(api_key='api_key',
                 plan_id=20.112,
                 card_hash='longcardhash32432',
                 customer=Customer(email='*****@*****.**'))
Beispiel #10
0
 def test_subscription_costumer_without_email(self):
     with self.assertRaises(ValueError):
         sub = Subscription(api_key='api_key',
                 plan_id=20112,
                 card_hash='longcardhash32432',
                 customer=Customer())