-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added unit tests and github workflows
- Loading branch information
Showing
5 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "pip" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Verify Script | ||
|
||
on: [push,workflow_dispatch,pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [ "3.10", "3.11" ] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Analysing the code with pylint | ||
run: | | ||
pylint --errors-only $(find src/ -name "*.py" | xargs) | ||
- name: Running tests | ||
run: | | ||
python -m unittest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/usr/bin/env python3 | ||
""" | ||
Unit Tests | ||
""" | ||
|
||
import unittest | ||
import pandas as pd | ||
from pandas.testing import assert_frame_equal | ||
from moneymoney_api import Account | ||
from moneymoney_sum_by_bank import sum_by_account | ||
|
||
|
||
class TestSumByBank(unittest.TestCase): | ||
|
||
def test_empty(self): | ||
df = sum_by_account([]) | ||
|
||
assert df.empty is True | ||
|
||
def test_single_account(self): | ||
accounts: list[Account] = [ | ||
Account(name='Test Bank A', balance=[[1000.00, 'EUR']], portfolio=False, group=False, bankCode='TES1') | ||
] | ||
|
||
df_expected = pd.DataFrame([{'bank': 'TES1', 'currency': 'EUR', 'balance': 1000.00}]).set_index(['bank', 'currency']) | ||
df = sum_by_account(accounts) | ||
|
||
assert_frame_equal(df_expected, df, check_exact=True) | ||
|
||
def test_single_account_no_bank_code(self): | ||
accounts: list[Account] = [ | ||
Account(name='Test Bank A', balance=[[1000.00, 'EUR']], portfolio=False, group=False, bankCode='', attributes={'bankIdentifier': 'TES1'}) | ||
] | ||
|
||
df_expected = pd.DataFrame([{'bank': 'TES1', 'currency': 'EUR', 'balance': 1000.00}]).set_index(['bank', 'currency']) | ||
df = sum_by_account(accounts) | ||
|
||
assert_frame_equal(df_expected, df, check_exact=True) | ||
|
||
def test_multi_accounts_same_bank(self): | ||
accounts: list[Account] = [ | ||
Account(name='Test Bank A', balance=[[1000.00, 'EUR']], portfolio=False, group=False, bankCode='TES1'), | ||
Account(name='Test Bank A', balance=[[490.18, 'EUR']], portfolio=False, group=False, bankCode='TES1') | ||
] | ||
|
||
df_expected = pd.DataFrame([{'bank': 'TES1', 'currency': 'EUR', 'balance': 1490.18}]).set_index(['bank', 'currency']) | ||
df = sum_by_account(accounts) | ||
|
||
assert_frame_equal(df_expected, df, check_exact=True) | ||
|
||
def test_multi_accounts(self): | ||
accounts: list[Account] = [ | ||
Account(name='Test Bank A', balance=[[1000.00, 'EUR']], portfolio=False, group=False, bankCode='TES1'), | ||
Account(name='Test Bank A', balance=[[490.18, 'EUR']], portfolio=False, group=False, bankCode='TES1IGNORED'), | ||
Account(name='Test Bank B', balance=[[0.99, 'EUR']], portfolio=False, group=False, bankCode='TES2'), | ||
Account(name='Test Bank C', balance=[[0, 'EUR']], portfolio=False, group=False, bankCode='TES3'), | ||
Account(name='Test Bank B', balance=[[0.9988, 'EUR']], portfolio=False, group=False, bankCode='TES2') | ||
] | ||
|
||
df_expected = pd.DataFrame([{'bank': 'TES1', 'currency': 'EUR', 'balance': 1490.18}, {'bank': 'TES2', 'currency': 'EUR', 'balance': 1.9888}, {'bank': 'TES3', 'currency': 'EUR', 'balance': 0}]).set_index(['bank', 'currency']) | ||
df = sum_by_account(accounts) | ||
|
||
assert_frame_equal(df_expected, df, check_exact=True) |