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

Merge branch 'fsho12' into 'master'

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

See merge request !13
parents 715a429c efcd1abd
No related branches found
Tags v0.6.3
1 merge request!13Fsho12, del 1: mulighet å returnere en liste av batcher uten vouchere
Pipeline #72890 passed
......@@ -3,7 +3,6 @@ import logging
import urllib.parse
from datetime import date
from typing import Union, Optional, List
import requests
from setra_client.models import (Batch,
......@@ -204,7 +203,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.
......@@ -224,9 +224,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):
"""
......
......@@ -3,8 +3,7 @@ import datetime
import json
import typing
from enum import Enum
from typing import Optional
from typing import Optional, TypeVar, List
import pydantic
......@@ -83,7 +82,8 @@ class Batch(BaseModel):
period: typing.Optional[str]
interface: str
vouchertype: typing.Optional[str]
vouchers: typing.List[Voucher]
batch_progress: typing.Optional[str]
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,
"batch_progress": "ubw_import_ok",
"vouchertype": 50
}
......@@ -18,6 +18,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