예제 #1
0
 def test_fail_invalid_array_size(self):
     payments = generateExampleUtilityPaymentsJson(n=50)
     payments2 = generateExampleUtilityPaymentsJson(n=55)
     payments = payments + payments2
     with self.assertRaises(InputErrors) as context:
         payments = starkbank.utilitypayment.create(payments)
     errors = context.exception.errors
     for error in errors:
         print(error)
         self.assertEqual('invalidJson', error.code)
     self.assertEqual(1, len(errors))
예제 #2
0
    def test_success(self):
        brcodePayment = generateExampleBrcodePaymentsJson(n=1)[0]
        boletoPayment = generateExampleBoletoPaymentsJson(n=1)[0]
        utilityPayment = generateExampleUtilityPaymentsJson(n=1)[0]
        taxPayment = generateExampleTaxPaymentsJson(n=1)[0]

        types = [
            "brcode-payment", "boleto-payment", "utility-payment",
            "tax-payment"
        ]
        previews = [
            starkbank.PaymentPreview(id=brcodePayment.brcode),
            starkbank.PaymentPreview(
                id=boletoPayment.bar_code or boletoPayment.line),
            starkbank.PaymentPreview(
                id=utilityPayment.bar_code or utilityPayment.line),
            starkbank.PaymentPreview(
                id=taxPayment.bar_code or taxPayment.line),
        ]

        previewedTypes = []
        for preview in starkbank.paymentpreview.create(previews=previews):
            print(preview)
            previewedTypes.append(preview.type)
        self.assertEqual(types, previewedTypes)

        for preview in previews:
            preview.scheduled = date.today() + timedelta(days=100)

        previewedTypes = []
        for preview in starkbank.paymentpreview.create(previews=previews):
            print(preview)
            previewedTypes.append(preview.type)
        self.assertEqual(types, previewedTypes)
예제 #3
0
 def test_success(self):
     payments = generateExampleUtilityPaymentsJson(n=5)
     try:
         payments = starkbank.utilitypayment.create(payments)
     except InputErrors as e:
         for error in e.errors:
             print(error)
             self.assertEqual('immediatePaymentOutOfTime', error.code)
예제 #4
0
 def test_fail_invalid_json_payment(self):
     payments = generateExampleUtilityPaymentsJson(n=4)
     payments[0].bar_code = None
     payments[2].description = None
     with self.assertRaises(InputErrors) as context:
         payments = starkbank.utilitypayment.create(payments)
     errors = context.exception.errors
     for error in errors:
         print(error)
         self.assertTrue(error.code in ["invalidJson", "invalidPayment", "immediatePaymentOutOfTime"])
     self.assertTrue(len(errors) == 2)
예제 #5
0
 def test_success(self):
     payments = generateExampleUtilityPaymentsJson(n=1, next_day=True)
     try:
         payments = starkbank.utilitypayment.create(payments)
     except InputErrors as e:
         for error in e.errors:
             print(error)
             self.assertEqual('immediatePaymentOutOfTime', error.code)
     else:
         try:
             starkbank.utilitypayment.delete(payments[0].id)
         except InputErrors as e:
             for error in e.errors:
                 print(error)
                 self.assertEqual('invalidAction', error.code)
예제 #6
0
    def test_success(self):
        brcodePayment = generateExampleBrcodePaymentsJson(n=1)[0]
        boletoPayment = generateExampleBoletoPaymentsJson(n=1)[0]
        taxPayment = generateExampleTaxPaymentsJson(n=1)[0]
        utilityPayment = generateExampleUtilityPaymentsJson(n=1)[0]

        previews = [
            starkbank.PaymentPreview(id=brcodePayment.brcode, scheduled=date.today() + timedelta(days=2)),
            starkbank.PaymentPreview(id=boletoPayment.bar_code or boletoPayment.line, scheduled=date.today() + timedelta(days=2)),
            starkbank.PaymentPreview(id=taxPayment.bar_code or taxPayment.line, scheduled=date.today() + timedelta(days=2)),
            starkbank.PaymentPreview(id=utilityPayment.bar_code or utilityPayment.line, scheduled=date.today() + timedelta(days=2)),
        ]

        for preview in starkbank.paymentpreview.create(previews=previews):
            print(preview)
            paymentClass = {
                "brcode-payment": BrcodePreview,
                "boleto-payment": BoletoPreview,
                "utility-payment": UtilityPreview,
                "tax-payment": TaxPreview,
            }[preview.type]
            self.assertIsInstance(preview.payment, paymentClass)
예제 #7
0
 def test_success(self):
     payments = generateExampleUtilityPaymentsJson(n=1, next_day=True)
     payments = starkbank.utilitypayment.create(payments)
     starkbank.utilitypayment.delete(payments[0].id)