|
| 1 | +import pytest |
| 2 | + |
| 3 | +from figo import FigoException |
1 | 4 | from figo.models import Account |
2 | 5 | from figo.models import AccountBalance |
3 | 6 | from figo.models import BankContact |
|
19 | 22 | from figo.models import Transaction |
20 | 23 | from figo.models import User |
21 | 24 |
|
| 25 | +from tests.test_writing_methods import CLIENT_ERROR |
| 26 | + |
| 27 | +HTTP_NOT_ACCEPTABLE = 406 |
| 28 | + |
22 | 29 |
|
23 | 30 | def test_create_account_from_dict(demo_session): |
24 | 31 | data = {"account_id": "A1.1", |
@@ -399,3 +406,34 @@ def test_create_security_from_dict(demo_session): |
399 | 406 | } |
400 | 407 | security = Security.from_dict(demo_session, data) |
401 | 408 | assert isinstance(security, Security) |
| 409 | + |
| 410 | +OLD_ERROR_FORMAT = { |
| 411 | + 'error': { |
| 412 | + 'code': None, |
| 413 | + 'data': {}, |
| 414 | + 'description': None, |
| 415 | + 'group': 'unknown', |
| 416 | + 'message': 'Unsupported language', |
| 417 | + 'name': 'Not Acceptable' |
| 418 | + }, |
| 419 | + 'status': HTTP_NOT_ACCEPTABLE |
| 420 | +} |
| 421 | +NEW_ERROR_FORMAT = { |
| 422 | + 'error': { |
| 423 | + 'code': CLIENT_ERROR, |
| 424 | + 'data': {}, |
| 425 | + 'description': 'Unsupported language', |
| 426 | + 'group': 'client' |
| 427 | + }, |
| 428 | + 'status': HTTP_NOT_ACCEPTABLE |
| 429 | +} |
| 430 | + |
| 431 | + |
| 432 | +@pytest.mark.parametrize('payload', [ |
| 433 | + OLD_ERROR_FORMAT, |
| 434 | + NEW_ERROR_FORMAT, |
| 435 | +]) |
| 436 | +def test_create_figo_exception_from_dict(payload): |
| 437 | + exc = FigoException.from_dict(payload) |
| 438 | + assert isinstance(exc, FigoException) |
| 439 | + |
0 commit comments