Exemple #1
0
 def test_subscription_status_must_changed(self):
     subscription.create(self.data)
     response = subscription.set_status(self.data['code'], 'suspend')
     self.assertEqual(response.status_code, 200)
     response = subscription.set_status(self.data['code'], 'activate')
     self.assertEqual(response.status_code, 200)
     response = subscription.set_status(self.data['code'], 'cancel')
     self.assertEqual(response.status_code, 200)
Exemple #2
0
 def test_subscription_data_must_be_changed(self):
     subscription.create(self.data)
     data = mock.plan_data()
     plan.create(data)
     self.data['plan']['code'] = data['code']
     code = self.data.pop('code')
     del self.data['customer']
     response = subscription.alter(code, self.data)
     self.assertEqual(response.status_code, 200)
Exemple #3
0
 def test_payment_details_must_be_returned(self):
     sub = subscription.create(self.data)
     invoices = payment.fetch_invoice_payments(sub.json()['invoice']['id'])
     response = payment.payment_details(
         invoices.json()['payments'][0]['id'])
     self.assertEqual(response.status_code, 200)
     self.assertIsInstance(response.json(), dict)
Exemple #4
0
 def test_coupon_must_be_removed_from_subscription(self):
     sub_data = mock.subscription_data()
     sub = subscription.create(sub_data)
     self.assertFalse('coupon' in sub.json())
     self.assertTrue(coupon.create(self.data).ok)
     self.assertTrue(coupon.remove(sub_data['code']).ok)
     response = subscription.fetch(sub_data['code'])
     self.assertFalse('coupon' in response.json())
Exemple #5
0
 def test_coupon_must_be_applied(self):
     sub_data = mock.subscription_data()
     sub = subscription.create(sub_data)
     self.assertFalse('coupon' in sub.json())
     self.assertTrue(coupon.create(self.data).ok)
     sleep(2)
     response = coupon.apply(sub_data['code'], self.data['code'])
     self.assertTrue(response.ok)
     sub = subscription.fetch(sub_data['code'])
     self.assertTrue('coupon' in sub.json())
Exemple #6
0
 def test_payment_retry_must_return_error_if_subscription_is_active(self):
     sub = subscription.create(self.data).json()
     invoice_id, sub_code = sub['invoice']['id'], sub['code']
     sleep(14)  # Waiting for payment processing.
     sub = subscription.fetch(sub_code)
     self.assertEqual('Pago',
                      sub.json()['invoice']['status']['description'])
     response = payment.retry_invoice_payment(invoice_id)
     self.assertEqual(response.status_code, 400)
     self.assertTrue('errors' in response.json())
Exemple #7
0
 def test_generate_bank_slip(self):
     self.data['payment_method'] = 'BOLETO'
     sub = subscription.create(self.data)
     date = datetime.now() + timedelta(5)
     self.assertTrue('boleto' in sub.json()['_links'])
     response = payment.generate_bank_slip(
         sub.json()['invoice']['id'],
         {
             "year": date.year,
             "month": date.month,
             "day": date.day
         },
     )
     self.assertTrue(response.status_code, 200)
     self.assertNotEqual(sub.json()['_links']['boleto'],
                         response.json()['_links']['boleto'])
Exemple #8
0
 def test_all_invoice_payments_must_be_returned(self):
     sub = subscription.create(self.data)
     response = payment.fetch_invoice_payments(sub.json()['invoice']['id'])
     self.assertEqual(response.status_code, 200)
     self.assertTrue('payments' in response.json())
Exemple #9
0
 def test_subscription_payment_method_must_be_changed(self):
     subscription.create(self.data)
     response = subscription.set_payment_method(self.data['code'], 'BOLETO')
     self.assertEqual(response.status_code, 200)
Exemple #10
0
 def test_subscription_details_must_be_returned(self):
     subscription.create(self.data)
     response = subscription.fetch(self.data['code'])
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.json()['code'], self.data['code'])
Exemple #11
0
 def test_signature_must_be_created_with_new_customer(self):
     self.data['customer'] = mock.customer_data()
     response = subscription.create(self.data, True)
     self.assertEqual(response.status_code, 201)
     self.assertEqual(response.json()['message'],
                      'Assinatura criada com sucesso')
Exemple #12
0
 def test_signature_must_be_created(self):
     response = subscription.create(self.data)
     self.assertEqual(response.status_code, 201)
     self.assertEqual(response.json()['message'],
                      'Assinatura criada com sucesso')