Exemplo n.º 1
0
    def test_find_by_id(self):
        response = '''
        {
            "name":"Meu Plano",
            "color":null,
            "object":"plan",
            "days":30,
            "payment_methods":[
                "boleto",
                "credit_card"
            ],
            "charges":null,
            "amount":10000,
            "installments":1,
            "trial_days":0,
            "date_created":"2014-12-23T12:07:57.000Z",
            "id":10846
        }
        '''

        httpretty.register_uri(
            httpretty.GET,
            self.api_endpoint + '/10846',
            body=response,
            status=200,
        )

        plan = Plan()
        plan.find_by_id(10846)
        self.assertEqual(plan.data['id'], 10846)
    def test_find_by_id(self):
        response = '''
        {
            "name":"Meu Plano",
            "color":null,
            "object":"plan",
            "days":30,
            "payment_methods":[
                "boleto",
                "credit_card"
            ],
            "charges":null,
            "amount":10000,
            "installments":1,
            "trial_days":0,
            "date_created":"2014-12-23T12:07:57.000Z",
            "id":10846
        }
        '''

        httpretty.register_uri(
            httpretty.GET,
            self.api_endpoint + '/10846',
            body=response,
            status=200,
        )

        plan = Plan()
        plan.find_by_id(10846)
        self.assertEqual(plan.data['id'], 10846)
Exemplo n.º 3
0
    def test_create(self):
        response = '''
        {
            "name":"Meu Plano",
            "color":null,
            "object":"plan",
            "days":30,
            "payment_methods":[
                "boleto",
                "credit_card"
            ],
            "charges":"10",
            "amount":10000,
            "installments":"1",
            "trial_days":10,
            "date_created":"2014-12-23T12:19:19.000Z",
            "id":10848
        }
        '''

        httpretty.register_uri(
            httpretty.POST,
            self.api_endpoint,
            body=response,
            status=200,
        )

        plan = Plan(amount='10000',
                    days=30,
                    name='Meu Plano',
                    trial_days=10,
                    charges=10,
                    installments=1)
        plan.create()
        self.assertEqual(plan.data['id'], 10848)
Exemplo n.º 4
0
 def test_can_create(self):
     plan = Plan(api_key='api_key',
                 name='Test plan',
                 color='red'
             )
     plan.create()
     self.assertEqual(20112, plan.data['id'])
    def test_create(self):
        response = '''
        {
            "name":"Meu Plano",
            "color":null,
            "object":"plan",
            "days":30,
            "payment_methods":[
                "boleto",
                "credit_card"
            ],
            "charges":"10",
            "amount":10000,
            "installments":"1",
            "trial_days":10,
            "date_created":"2014-12-23T12:19:19.000Z",
            "id":10848
        }
        '''

        httpretty.register_uri(
            httpretty.POST,
            self.api_endpoint,
            body=response,
            status=200,
        )

        plan = Plan(
            amount='10000', days=30, name='Meu Plano', trial_days=10,
            charges=10, installments=1
        )
        plan.create()
        self.assertEqual(plan.data['id'], 10848)
Exemplo n.º 6
0
 def test_create_plan_error(self):
     plan = Plan(api_key='api_key')
     with self.assertRaises(PagarmeApiError):
         plan.create()
Exemplo n.º 7
0
 def test_get_plan_by_id_error(self):
     plan = Plan(api_key='api_key')
     with self.assertRaises(PagarmeApiError):
         plan.find_by_id(20112)
Exemplo n.º 8
0
 def test_get_plan_by_id(self):
     plan = Plan(api_key='api_key')
     plan.find_by_id(20112)
     self.assertEqual(20112, plan.data['id'])
Exemplo n.º 9
0
 def test_plan_without_api_key(self):
     with self.assertRaises(ValueError):
         plan = Plan(name='Test Plan', color='red')
Exemplo n.º 10
0
 def test_plan_invalid_payment_method(self):
     with self.assertRaises(ValueError):
         plan = Plan(api_key='api_key', name='Test Plan', color='red', payment_methods=['rice'])