|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# Copyright (C) 2020 Roald Nefs <info@roaldnefs.com> |
| 4 | +# |
| 5 | +# This file is part of python-transip. |
| 6 | + |
| 7 | +# python-transip is free software: you can redistribute it and/or modify |
| 8 | +# it under the terms of the GNU Lesser General Public License as published by |
| 9 | +# the Free Software Foundation, either version 3 of the License, or |
| 10 | +# (at your option) any later version. |
| 11 | + |
| 12 | +# python-transip is distributed in the hope that it will be useful, |
| 13 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | +# GNU Lesser General Public License for more details. |
| 16 | + |
| 17 | +# You should have received a copy of the GNU Lesser General Public License |
| 18 | +# along with python-transip. If not, see <https://www.gnu.org/licenses/>. |
| 19 | + |
| 20 | +from typing import Type, List |
| 21 | +import responses # type: ignore |
| 22 | + |
| 23 | +from transip import TransIP |
| 24 | +from transip.v6.objects import Invoice |
| 25 | + |
| 26 | + |
| 27 | +@responses.activate |
| 28 | +def test_invoices_list(transip_minimal_client: Type[TransIP]) -> None: |
| 29 | + responses.add( |
| 30 | + responses.GET, |
| 31 | + "https://api.transip.nl/v6/invoices", |
| 32 | + json={ |
| 33 | + "invoices": [ |
| 34 | + { |
| 35 | + "invoiceNumber": "F0000.1911.0000.0004", |
| 36 | + "creationDate": "2020-01-01", |
| 37 | + "payDate": "2020-01-01", |
| 38 | + "dueDate": "2020-02-01", |
| 39 | + "invoiceStatus": "waitsforpayment", |
| 40 | + "currency": "EUR", |
| 41 | + "totalAmount": 1000, |
| 42 | + "totalAmountInclVat": 1240 |
| 43 | + } |
| 44 | + ] |
| 45 | + }, |
| 46 | + status=200, |
| 47 | + ) |
| 48 | + |
| 49 | + invoices: List[Type[Invoice]] = transip_minimal_client.invoices.list() |
| 50 | + invoice: Type[Invoice] = invoices[0] |
| 51 | + assert len(invoices) == 1 |
| 52 | + assert invoice.get_id() == "F0000.1911.0000.0004" # type: ignore |
| 53 | + |
| 54 | + |
| 55 | +@responses.activate |
| 56 | +def test_invoices_get(transip_minimal_client: Type[TransIP]) -> None: |
| 57 | + responses.add( |
| 58 | + responses.GET, |
| 59 | + "https://api.transip.nl/v6/invoices/F0000.1911.0000.0004", |
| 60 | + json={ |
| 61 | + "invoice": { |
| 62 | + "invoiceNumber": "F0000.1911.0000.0004", |
| 63 | + "creationDate": "2020-01-01", |
| 64 | + "payDate": "2020-01-01", |
| 65 | + "dueDate": "2020-02-01", |
| 66 | + "invoiceStatus": "waitsforpayment", |
| 67 | + "currency": "EUR", |
| 68 | + "totalAmount": 1000, |
| 69 | + "totalAmountInclVat": 1240 |
| 70 | + } |
| 71 | + }, |
| 72 | + status=200, |
| 73 | + ) |
| 74 | + |
| 75 | + invoice_id: str = "F0000.1911.0000.0004" |
| 76 | + invoice: Type[Invoice] = transip_minimal_client.invoices.get(invoice_id) |
| 77 | + assert invoice.get_id() == "F0000.1911.0000.0004" # type: ignore |
0 commit comments