From 7d3d6693e8e577ca5c48fc08bb0ee639367a5554 Mon Sep 17 00:00:00 2001 From: Youe Graillot Date: Mon, 13 Dec 2021 01:15:49 +0100 Subject: [PATCH] fix tests --- ihatemoney/models.py | 8 ++++---- ihatemoney/tests/main_test.py | 2 +- ihatemoney/web.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ihatemoney/models.py b/ihatemoney/models.py index ef3f5c872..50f919b48 100644 --- a/ihatemoney/models.py +++ b/ihatemoney/models.py @@ -322,7 +322,7 @@ def switch_currency(self, new_currency): db.session.add(self) db.session.commit() - def import_bills(self, bills: list[dict]): + def import_bills(self, bills: list): """Import bills from a list of dictionaries""" # Add members not already in the project members_project = [str(m) for m in self.members] @@ -621,14 +621,14 @@ def delete(self, project, id): def __init__( self, amount: float, - date: object = None, + date: datetime = None, external_link: str = "", original_currency: str = "", - owers: list[Person] = [], + owers: list = [], payer_id: int = None, project_default_currency: str = "", what: str = "", - ) -> None: + ): super().__init__() self.amount = amount self.date = date diff --git a/ihatemoney/tests/main_test.py b/ihatemoney/tests/main_test.py index bd5e7ddcf..fac655d31 100644 --- a/ihatemoney/tests/main_test.py +++ b/ihatemoney/tests/main_test.py @@ -153,7 +153,7 @@ def test_bill_pay_each(self): }, ) - project = self.get_project_by_name(name="raclette") + project = models.Project.query.get_by_name(name="raclette") zorglub = models.Person.query.get_by_name(name="zorglub", project=project) zorglub_bills = models.Bill.query.options( orm.subqueryload(models.Bill.owers) diff --git a/ihatemoney/web.py b/ihatemoney/web.py index f0d8d709d..02d736489 100644 --- a/ihatemoney/web.py +++ b/ihatemoney/web.py @@ -13,7 +13,6 @@ import json import os -from dateutil.parser import parse from dateutil.relativedelta import relativedelta from flask import ( Blueprint, @@ -454,7 +453,7 @@ def import_project(): elif data.mimetype == "text/csv": try: bills = csv2list_of_dicts(data) - except Exception as b: + except Exception: raise ValueError(_("Unable to parse CSV")) else: raise ValueError("Unsupported file type") @@ -484,7 +483,8 @@ def import_project(): if len(currencies - {CurrencyConverter.no_currency}) >= 2: raise ValueError( _( - "Cannot add bills in multiple currencies to a project without default currency" + "Cannot add bills in multiple currencies to a project without default " + "currency" ) ) # Strip currency from bills (since it's the same for every bill)