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): ...@@ -190,7 +190,8 @@ class SetraClient(object):
min_created_date: Optional[date] = None, min_created_date: Optional[date] = None,
max_created_date: Optional[date] = None, max_created_date: Optional[date] = None,
batch_progress: Optional[BatchProgressEnum] = 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. GETs one or all batches from SETRA.
...@@ -210,9 +211,12 @@ class SetraClient(object): ...@@ -210,9 +211,12 @@ class SetraClient(object):
'interface': interface} 'interface': interface}
url = self.urls.batch(batch_id) url = self.urls.batch(batch_id)
response = self.get(url, params=params) 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): def get_voucher(self, vouch_id: int = None):
""" """
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import datetime import datetime
import json import json
import typing import typing
from typing import Optional, TypeVar from typing import Optional, TypeVar, List
from enum import Enum from enum import Enum
import pydantic import pydantic
...@@ -84,7 +84,7 @@ class Batch(BaseModel): ...@@ -84,7 +84,7 @@ class Batch(BaseModel):
period: typing.Optional[str] period: typing.Optional[str]
interface: str interface: str
vouchertype: typing.Optional[str] vouchertype: typing.Optional[str]
vouchers: typing.List[Voucher] vouchers: typing.Optional[typing.List[Voucher]]
class ErrorTransaction(BaseModel): class ErrorTransaction(BaseModel):
......
...@@ -82,6 +82,11 @@ def batch_with_voucher_fixture(): ...@@ -82,6 +82,11 @@ def batch_with_voucher_fixture():
return load_json_file('batch_with_voucher_fixture.json') 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 @pytest.fixture
def batch_fail_fixture(): def batch_fail_fixture():
return load_json_file('batch_fail_fixture.json') 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): ...@@ -17,6 +17,10 @@ def test_batch(batch_fixture):
assert 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): def test_voucher(voucher_fixture):
assert 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