Skip to content

Commit

Permalink
facelift, wip
Browse files Browse the repository at this point in the history
  • Loading branch information
honzajavorek committed Dec 25, 2024
1 parent 04154d2 commit a970114
Show file tree
Hide file tree
Showing 11 changed files with 594 additions and 155 deletions.
21 changes: 0 additions & 21 deletions .editorconfig

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,6 @@ dmypy.json

# Cython debug symbols
cython_debug/

# pytest
.pytest_cache
32 changes: 0 additions & 32 deletions CHANGELOG.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2024, Honza Javorek <[email protected]>
Copyright (c) 2025, Honza Javorek <[email protected]>

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

Expand Down
43 changes: 19 additions & 24 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
fiobank
=======

|PyPI version| |Build Status| |Test Coverage|

`Fio Bank API <http://www.fio.cz/bank-services/internetbanking-api>`__
`Fio Bank API <http://www.fio.cz/bank-services/internetbanking-api>`_
in Python.

Installation
------------

.. code:: sh
From PyPI::

pip install fiobank

$ pip install fiobank
In case you have an adventurous mind, give a try to the source::

pip install git+https://github.com/honzajavorek/fiobank.git#egg=fiobank

Usage
-----
Expand Down Expand Up @@ -76,35 +78,28 @@ Listing the latest transactions:
Conflict Error
--------------

`Fio API documentation <http://www.fio.cz/docs/cz/API_Bankovnictvi.pdf>`__
(Section 8.2) states that a single token should be used only once per
`Fio API documentation <http://www.fio.cz/docs/cz/API_Bankovnictvi.pdf>`_
(Section 8.3) states that a single token should be used only once per
30s. Otherwise, an HTTP 409 Conflict will be returned and
``fiobank.ThrottlingError`` will be raised.

Contributing
------------
Development
-----------

.. code:: shell
Install using `poetry <https://python-poetry.org/>`_::

$ pip install -e .[tests]
$ pytest
git clone [email protected]:honzajavorek/fiobank.git
cd fiobank
poetry install

Changelog
---------
Then run tests::

See `GitHub Releases <https://github.com/honzajavorek/fiobank/releases>`_.
pytest

License: ISC
------------

© 2024 Honza Javorek [email protected]
© 2025 Honza Javorek <[email protected]>

This work is licensed under the `ISC
license <https://en.wikipedia.org/wiki/ISC_license>`__.

.. |PyPI version| image:: https://badge.fury.io/py/fiobank.svg
:target: https://badge.fury.io/py/fiobank
.. |Build Status| image:: https://github.com/honzajavorek/fiobank/actions/workflows/test.yml/badge.svg
:target: https://github.com/honzajavorek/fiobank/actions/workflows/test.yml
.. |Test Coverage| image:: https://coveralls.io/repos/github/honzajavorek/fiobank/badge.svg?branch=master
:target: https://coveralls.io/github/honzajavorek/fiobank?branch=master
license <https://en.wikipedia.org/wiki/ISC_license>`_.
9 changes: 9 additions & 0 deletions fiobank.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from decimal import Decimal
import re
from decimal import Decimal
from datetime import datetime, date
import warnings

Expand All @@ -9,6 +10,14 @@
__all__ = ("FioBank", "ThrottlingError")


def coerce_amount(value):
if isinstance(value, int):
return Decimal(value)
if isinstance(value, float):
return Decimal(str(value))
raise ValueError(value)


def coerce_date(value):
if isinstance(value, datetime):
return value.date()
Expand Down
500 changes: 500 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[tool.poetry]
name = "fiobank"
version = "4.0.0"
description = "Fio Bank API in Python (unofficial)"
authors = ["Honza Javorek <[email protected]>"]
license = "ICS"
readme = "README.rst"
repository = "https://github.com/honzajavorek/fiobank"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: ISC License (ISCL)",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Internet",
]

[tool.poetry.dependencies]
python = "^3.7"
requests = "^2.28.2"

[tool.poetry.group.dev.dependencies]
pytest = "^7.2.1"
pylama = "^8.4.1"
responses = "^0.22.0"
mock = "^5.0.1"

[tool.pytest.ini_options]
testpaths = "tests"
norecursedirs = "env venv .git"

[tool.pylama]
skip = "env/*,venv/*"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
13 changes: 0 additions & 13 deletions setup.cfg

This file was deleted.

58 changes: 0 additions & 58 deletions setup.py

This file was deleted.

30 changes: 24 additions & 6 deletions tests/test_fiobank.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from decimal import Decimal
from unittest import mock

import re
import os
import uuid
import json
from datetime import date
from decimal import Decimal

import pytest
import requests
import responses

from fiobank import FioBank


Expand Down Expand Up @@ -113,7 +114,7 @@ def test_info_is_case_insensitive(transactions_json):


@pytest.mark.parametrize(
"api_key,sdk_key",
"api_key, sdk_key",
[
("accountId", "account_number"),
("bankId", "bank_code"),
Expand Down Expand Up @@ -154,7 +155,7 @@ def test_info_parse_no_account_number_full(transactions_json):


@pytest.mark.parametrize(
"method,args,kwargs",
"method, args, kwargs",
[
("period", [date(2016, 8, 4), date(2016, 8, 30)], {}),
("period", ["2016-08-04", "2016-08-30"], {}),
Expand Down Expand Up @@ -274,7 +275,7 @@ def test_transaction_schema_is_complete():


@pytest.mark.parametrize(
"api_key,sdk_key,sdk_type",
"api_key, sdk_key, sdk_type",
[
(api_key, sdk_key, sdk_type)
for api_key, (sdk_key, sdk_type) in FioBank("...").transaction_schema.items()
Expand Down Expand Up @@ -305,6 +306,23 @@ def test_transactions_parse(transactions_json, api_key, sdk_key, sdk_type):
assert sdk_transaction[sdk_key] == sdk_type(api_transaction[api_key]["value"])


@pytest.mark.parametrize('amount, expected', [
(42, Decimal('42')),
(0, Decimal('0')),
(-353.2933, Decimal('-353.2933')),
(3.14, Decimal('3.14')),
])
def test_transactions_parse_amount(transactions_json, amount, expected):
client = FioBank('...')

api_transaction = transactions_json['accountStatement']['transactionList']['transaction'][0] # NOQA
api_transaction['column1'] = amount

sdk_transaction = list(client._parse_transactions(transactions_json))[0]

assert sdk_transaction['amount'] == expected


def test_transactions_parse_unsanitized(transactions_json):
client = FioBank("...")

Expand Down Expand Up @@ -370,7 +388,7 @@ def test_amount_re(test_input):


@pytest.mark.parametrize(
"test_input,amount,currency",
"test_input, amount, currency",
[
("650.00 HRK", 650.0, "HRK"),
("-308 EUR", -308.0, "EUR"),
Expand All @@ -395,7 +413,7 @@ def test_transactions_parse_amount_as_float(


@pytest.mark.parametrize(
"test_input,amount,currency",
"test_input, amount, currency",
[
("650.00 HRK", Decimal("650.0"), "HRK"),
("-308 EUR", Decimal("-308.0"), "EUR"),
Expand Down

0 comments on commit a970114

Please sign in to comment.