diff --git a/dkb_robo/portfolio.py b/dkb_robo/portfolio.py index f252ba2..fe3454f 100644 --- a/dkb_robo/portfolio.py +++ b/dkb_robo/portfolio.py @@ -204,7 +204,7 @@ def _details(self, account: Dict[str, str], aid: str) -> Dict[str, str]: for my_field, dkb_field in mapping_dic.items(): if my_field == 'limit': try: - output_dic[my_field] = float(account.get('attributes', {}).get(dkb_field, None)) + output_dic[my_field] = float(account.get('attributes', {}).get(dkb_field, 0)) except Exception as exc: self.logger.error('limit conversion error: %s', exc) output_dic[my_field] = None @@ -265,7 +265,7 @@ def _details(self, card: Dict[str, str], cid: str) -> Dict[str, str]: self.logger.debug('portfolio.Card._details()\n') try: - limit = float(card.get('attributes', {}).get('limit', {}).get('value', None)) + limit = float(card.get('attributes', {}).get('limit', {}).get('value', 0)) except Exception as exc: self.logger.error('limit conversion error: %s', exc) limit = None diff --git a/dkb_robo/standingorder.py b/dkb_robo/standingorder.py index 3f9113a..35b1ebf 100644 --- a/dkb_robo/standingorder.py +++ b/dkb_robo/standingorder.py @@ -22,7 +22,7 @@ def _filter(self, full_list: Dict[str, str]) -> List[Dict[str, str]]: for ele in full_list['data']: try: - amount = float(ele.get('attributes', {}).get('amount', {}).get('value', None)) + amount = float(ele.get('attributes', {}).get('amount', {}).get('value', 0)) except Exception as err: self.logger.error('api.StandingOrder._filter() error: %s', err) amount = None diff --git a/test/test_portfolio.py b/test/test_portfolio.py index c10576d..0196a5c 100644 --- a/test/test_portfolio.py +++ b/test/test_portfolio.py @@ -311,9 +311,7 @@ def test_018__sort(self): 'status': {'category': 'active'}, 'transactions': None, 'type': 'debitcard'}} - with self.assertLogs('dkb_robo', level='INFO') as lcm: - self.assertEqual(result, self.overview._sort(data)) - self.assertIn("ERROR:dkb_robo:limit conversion error: float() argument must be a string or a real number, not 'NoneType'", lcm.output) + self.assertEqual(result, self.overview._sort(data)) def test_019__sort(self): """ test _sort() """ @@ -423,9 +421,7 @@ def test_019__sort(self): 'productgroup': None, 'transactions': 'https://banking.dkb.de/api/broker/brokerage-accounts/baccountid1/positions?include=instrument%2Cquote', 'type': 'depot'}} - with self.assertLogs('dkb_robo', level='INFO') as lcm: - self.assertEqual(result, self.overview._sort(data)) - self.assertIn("ERROR:dkb_robo:limit conversion error: float() argument must be a string or a real number, not 'NoneType'", lcm.output) + self.assertEqual(result, self.overview._sort(data)) class TestAccount(unittest.TestCase): """ test class """ @@ -455,9 +451,7 @@ def test_022__balance(self): def test_023__details(self): """ test _details() """ account = {'attributes': {'iban': 'iban', 'bic': 'bic', 'accountNumber': 'accountNumber', 'bankCode': 'bankCode', 'accountType': 'accountType', 'balance': 'balance'}} - with self.assertLogs('dkb_robo', level='INFO') as lcm: - self.assertEqual({'type': 'account', 'name': None, 'id': 'aid', 'transactions': 'https://banking.dkb.de/api/accounts/accounts/aid/transactions', 'date': None, 'iban': 'iban', 'account': 'iban', 'holdername': None, 'limit': None}, self.account._details(account, 'aid')) - self.assertIn("ERROR:dkb_robo:limit conversion error: float() argument must be a string or a real number, not 'NoneType'", lcm.output) + self.assertEqual({'type': 'account', 'name': None, 'id': 'aid', 'transactions': 'https://banking.dkb.de/api/accounts/accounts/aid/transactions', 'date': None, 'iban': 'iban', 'account': 'iban', 'holdername': None, 'limit': 0.0}, self.account._details(account, 'aid')) @patch('dkb_robo.portfolio.Account._balance') @patch('dkb_robo.portfolio.Account._details') diff --git a/test/test_standingorder.py b/test/test_standingorder.py index d7a03cd..f016b4f 100644 --- a/test/test_standingorder.py +++ b/test/test_standingorder.py @@ -126,10 +126,8 @@ def test_007__filter(self): } } }]} - result = [{'amount': None, 'currencycode': None, 'purpose': 'description', 'recpipient': 'cardname', 'creditoraccount': {'iban': 'crediban', 'bic': 'credbic'}, 'interval': {'from': '2020-01-01', 'until': '2025-12-01', 'frequency': 'monthly', 'nextExecutionAt': '2020-02-01'}}] - with self.assertLogs('dkb_robo', level='INFO') as lcm: - self.assertEqual(result, self.dkb._filter(full_list)) - self.assertIn("ERROR:dkb_robo:api.StandingOrder._filter() error: float() argument must be a string or a real number, not 'NoneType'", lcm.output) + result = [{'amount': 0.0, 'currencycode': None, 'purpose': 'description', 'recpipient': 'cardname', 'creditoraccount': {'iban': 'crediban', 'bic': 'credbic'}, 'interval': {'from': '2020-01-01', 'until': '2025-12-01', 'frequency': 'monthly', 'nextExecutionAt': '2020-02-01'}}] + self.assertEqual(result, self.dkb._filter(full_list)) if __name__ == '__main__':