Improve bpvf tests
This commit is contained in:
parent
2ac1139d61
commit
e2218c021e
2 changed files with 55 additions and 6 deletions
|
@ -1,39 +1,88 @@
|
||||||
|
import datetime
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from ofx_processor.processors.bpvf import BpvfLine
|
from ofx_processor.processors.bpvf import BpvfLine
|
||||||
|
|
||||||
|
|
||||||
class MyTestCase(unittest.TestCase):
|
class BpvfTransaction:
|
||||||
|
"""
|
||||||
|
Mimick what is retrieved via ofxtools when parsing the file
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
name: str = "",
|
||||||
|
memo: str = "",
|
||||||
|
dtposted: datetime.datetime = None,
|
||||||
|
trnamt: float = 0,
|
||||||
|
):
|
||||||
|
self.dtposted = dtposted
|
||||||
|
self.memo = memo
|
||||||
|
self.trnamt = trnamt
|
||||||
|
self.name = name
|
||||||
|
|
||||||
|
|
||||||
|
class BpvfProcessorTestCase(unittest.TestCase):
|
||||||
def test_process_name_and_memo_no_change(self):
|
def test_process_name_and_memo_no_change(self):
|
||||||
name = "business"
|
name = "business"
|
||||||
memo = "2020-01-17"
|
memo = "2020-01-17"
|
||||||
|
transaction = BpvfTransaction(name=name, memo=memo)
|
||||||
|
|
||||||
result_name, result_memo = BpvfLine._process_name_and_memo(name, memo)
|
line = BpvfLine(transaction)
|
||||||
|
result_name = line.get_payee()
|
||||||
|
result_memo = line.get_memo()
|
||||||
self.assertEqual(result_name, name)
|
self.assertEqual(result_name, name)
|
||||||
self.assertEqual(result_memo, memo)
|
self.assertEqual(result_memo, memo)
|
||||||
|
|
||||||
def test_process_name_and_memo_change_required_with_conversion(self):
|
def test_process_name_and_memo_change_required_with_conversion(self):
|
||||||
name = "150120 CB****5874"
|
name = "150120 CB****5874"
|
||||||
memo = "GUY AND SONS FR LYON 0,90EUR 1 EURO = 1,000000"
|
memo = "GUY AND SONS FR LYON 0,90EUR 1 EURO = 1,000000"
|
||||||
|
transaction = BpvfTransaction(name=name, memo=memo)
|
||||||
|
|
||||||
expected_name = "GUY AND SONS FR LYON"
|
expected_name = "GUY AND SONS FR LYON"
|
||||||
expected_memo = "150120 CB****5874 0,90EUR 1 EURO = 1,000000"
|
expected_memo = "150120 CB****5874 0,90EUR 1 EURO = 1,000000"
|
||||||
|
|
||||||
result_name, result_memo = BpvfLine._process_name_and_memo(name, memo)
|
line = BpvfLine(transaction)
|
||||||
|
result_name = line.get_payee()
|
||||||
|
result_memo = line.get_memo()
|
||||||
self.assertEqual(result_name, expected_name)
|
self.assertEqual(result_name, expected_name)
|
||||||
self.assertEqual(result_memo, expected_memo)
|
self.assertEqual(result_memo, expected_memo)
|
||||||
|
|
||||||
def test_process_name_and_memo_change_required_no_conversion(self):
|
def test_process_name_and_memo_change_required_no_conversion(self):
|
||||||
name = "150120 CB****5874"
|
name = "150120 CB****5874"
|
||||||
memo = "Dott 75PARIS"
|
memo = "Dott 75PARIS"
|
||||||
|
transaction = BpvfTransaction(name=name, memo=memo)
|
||||||
|
|
||||||
expected_name = "Dott 75PARIS"
|
expected_name = "Dott 75PARIS"
|
||||||
expected_memo = "150120 CB****5874"
|
expected_memo = "150120 CB****5874"
|
||||||
|
|
||||||
result_name, result_memo = BpvfLine._process_name_and_memo(name, memo)
|
line = BpvfLine(transaction)
|
||||||
|
result_name = line.get_payee()
|
||||||
|
result_memo = line.get_memo()
|
||||||
self.assertEqual(result_name, expected_name)
|
self.assertEqual(result_name, expected_name)
|
||||||
self.assertEqual(result_memo, expected_memo)
|
self.assertEqual(result_memo, expected_memo)
|
||||||
|
|
||||||
|
def test_get_date(self):
|
||||||
|
transaction = BpvfTransaction(dtposted=datetime.datetime(2020, 1, 23, 1, 2, 3))
|
||||||
|
expected_date = "2020-01-23"
|
||||||
|
|
||||||
|
result_date = BpvfLine(transaction).get_date()
|
||||||
|
self.assertEqual(result_date, expected_date)
|
||||||
|
|
||||||
|
def test_get_amount_positive(self):
|
||||||
|
transaction = BpvfTransaction(trnamt=52.2)
|
||||||
|
expected_amount = 52200
|
||||||
|
|
||||||
|
result_amount = BpvfLine(transaction).get_amount()
|
||||||
|
self.assertEqual(result_amount, expected_amount)
|
||||||
|
|
||||||
|
def test_get_amount_negative(self):
|
||||||
|
transaction = BpvfTransaction(trnamt=-52.2)
|
||||||
|
expected_amount = -52200
|
||||||
|
|
||||||
|
result_amount = BpvfLine(transaction).get_amount()
|
||||||
|
self.assertEqual(result_amount, expected_amount)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main() # pragma: nocover
|
||||||
|
|
|
@ -71,4 +71,4 @@ class RevolutProcessorTestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main() # pragma: nocover
|
||||||
|
|
Loading…
Reference in a new issue