def get_summary_by_account( *, db_session: Session = Depends(get_db), name: str, start_date: date = None, end_date: date = None, ) -> TransactionSummaryByAccount: user = User.get_user_by_name(db_session=db_session, name=name) if user is None: raise HTTPException(status_code=HTTP_404_NOT_FOUND, detail=messages.USER_NOT_FOUND) return Transaction.get_summary_by_account(db_session=db_session, user_id=user.id, start_date=start_date, end_date=end_date)
def test_transaction_get_summary_by_account_ok(session, new_user, scenario): expected = [ { "account": "C00099", "balance": 1738.87, "total_inflow": 2500.72, "total_outflow": -761.85 }, { "account": "S00012", "balance": 150.72, "total_inflow": 150.72, "total_outflow": 0.00 }, ] assert Transaction.get_summary_by_account(db_session=session, user_id=new_user.id) == expected
def test_transaction_get_summary_by_account_empty(session, new_user): assert Transaction.get_summary_by_account(db_session=session, user_id=new_user.id) == []