Skip to content
Snippets Groups Projects
Commit cb0774cc authored by Petr Kalashnikov's avatar Petr Kalashnikov
Browse files

FSHO12, del 1: mulighet å returnere en liste av batcher uten vouchere

parent 8a3b9134
No related branches found
No related tags found
1 merge request!13Fsho12, del 1: mulighet å returnere en liste av batcher uten vouchere
Pipeline #69213 passed
......@@ -190,7 +190,8 @@ class SetraClient(object):
min_created_date: Optional[date] = None,
max_created_date: Optional[date] = None,
batch_progress: Optional[BatchProgressEnum] = None,
interface: Optional[str] = None):
interface: Optional[str] = None,
return_list_of_obj: Optional[bool] = False):
"""
GETs one or all batches from SETRA.
......@@ -210,9 +211,12 @@ class SetraClient(object):
'interface': interface}
url = self.urls.batch(batch_id)
response = self.get(url, params=params)
return response.json()
data = response.json()
if return_list_of_obj:
return [Batch(**item) for item in data]
else:
return data
def get_voucher(self, vouch_id: int = None):
"""
......
......@@ -2,7 +2,7 @@
import datetime
import json
import typing
from typing import Optional, TypeVar
from typing import Optional, TypeVar, List
from enum import Enum
import pydantic
......@@ -84,7 +84,7 @@ class Batch(BaseModel):
period: typing.Optional[str]
interface: str
vouchertype: typing.Optional[str]
vouchers: typing.List[Voucher]
vouchers: typing.Optional[typing.List[Voucher]]
class ErrorTransaction(BaseModel):
......
......@@ -82,6 +82,11 @@ def batch_with_voucher_fixture():
return load_json_file('batch_with_voucher_fixture.json')
@pytest.fixture
def batch_without_voucher_field():
return load_json_file('batch_without_voucher_field.json')
@pytest.fixture
def batch_fail_fixture():
return load_json_file('batch_fail_fixture.json')
......
{
"client": 10,
"batchid": 20,
"period": 30,
"interface": 40,
"vouchertype": 50
}
......@@ -17,6 +17,10 @@ def test_batch(batch_fixture):
assert Batch(**batch_fixture)
def test_batch(batch_without_voucher_field):
assert Batch(**batch_without_voucher_field)
def test_voucher(voucher_fixture):
assert Voucher(**voucher_fixture)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment