Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mariofix committed Dec 13, 2024
1 parent 5b06a01 commit f284843
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
28 changes: 14 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-toml
- id: check-added-large-files
- id: check-case-conflict
- id: mixed-line-ending
- repo: https://github.com/pycqa/isort
- id: end-of-file-fixer
- id: check-toml
- id: check-added-large-files
- id: check-case-conflict
- id: mixed-line-ending
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/psf/black
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/asottile/pyupgrade
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.0
hooks:
- id: pyupgrade
- id: pyupgrade
args: [--py39-plus]
- repo: https://github.com/hhatto/autopep8
- repo: https://github.com/hhatto/autopep8
rev: v2.3.1
hooks:
- id: autopep8
- repo: https://github.com/PyCQA/flake8
- id: autopep8
- repo: https://github.com/PyCQA/flake8
rev: "7.1.1"
hooks:
- id: flake8
Expand Down
5 changes: 2 additions & 3 deletions django_payments_chile/FlowProvider.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from dataclasses import asdict
from typing import Any, Optional
from urllib import request
import requests

import requests
from django.http import HttpResponseBadRequest, JsonResponse
from payments import PaymentError, PaymentStatus, RedirectNeeded
from payments.core import BasicProvider, get_base_url
Expand Down Expand Up @@ -215,7 +214,7 @@ def refund(self, payment, amount: Optional[int] = None) -> int:
"commerceTrxId": payment.token,
"flowTrxId": payment.attrs.respuesta_flow["flowOrder"],
}
refund = FlowRefund.create(self._client, datos_reembolso)
refund = datos_reembolso # FlowRefund.create(self._client, datos_reembolso)
except Exception as pe:
raise PaymentError(pe)
else:
Expand Down
14 changes: 8 additions & 6 deletions tests/test_flowprovider.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from unittest import TestCase
from unittest.mock import Mock
from unittest.mock import patch
from unittest.mock import Mock, patch

from payments import PaymentStatus
from payments import RedirectNeeded
from payments import PaymentStatus, RedirectNeeded

from django_payments_chile.FlowProvider import FlowProvider

Expand Down Expand Up @@ -46,6 +44,10 @@ def get_success_url(self):
return "http://mi-app.cl/exito"


class TestException(Exception):
pass


class TestFlowProviderV3(TestCase):
def test_provider_create_session_success(self):
payment = Payment()
Expand All @@ -71,10 +73,10 @@ def test_provider_create_session_error(self):
with patch("django_payments_chile.FlowProvider.requests.post") as mock_post:
# Simulate an error response
mock_response = Mock()
mock_response.raise_for_status.side_effect = Exception("Error occurred")
mock_response.raise_for_status.side_effect = TestException("Error occurred")
mock_post.return_value = mock_response

with self.assertRaises(Exception):
with self.assertRaises(TestException):
provider.get_form(payment)

self.assertEqual(payment.status, PaymentStatus.ERROR)
Expand Down
1 change: 0 additions & 1 deletion tienda_pruebas/tienda/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

from django.contrib import admin
from django.urls import include, path

from pagos.views import crear_pago

urlpatterns = [
Expand Down

0 comments on commit f284843

Please sign in to comment.