mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 12:41:49 +02:00
fix tests
This commit is contained in:
parent
ef92181786
commit
7d3d6693e8
3 changed files with 8 additions and 8 deletions
|
@ -322,7 +322,7 @@ class Project(db.Model):
|
||||||
db.session.add(self)
|
db.session.add(self)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
def import_bills(self, bills: list[dict]):
|
def import_bills(self, bills: list):
|
||||||
"""Import bills from a list of dictionaries"""
|
"""Import bills from a list of dictionaries"""
|
||||||
# Add members not already in the project
|
# Add members not already in the project
|
||||||
members_project = [str(m) for m in self.members]
|
members_project = [str(m) for m in self.members]
|
||||||
|
@ -621,14 +621,14 @@ class Bill(db.Model):
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
amount: float,
|
amount: float,
|
||||||
date: object = None,
|
date: datetime = None,
|
||||||
external_link: str = "",
|
external_link: str = "",
|
||||||
original_currency: str = "",
|
original_currency: str = "",
|
||||||
owers: list[Person] = [],
|
owers: list = [],
|
||||||
payer_id: int = None,
|
payer_id: int = None,
|
||||||
project_default_currency: str = "",
|
project_default_currency: str = "",
|
||||||
what: str = "",
|
what: str = "",
|
||||||
) -> None:
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.amount = amount
|
self.amount = amount
|
||||||
self.date = date
|
self.date = date
|
||||||
|
|
|
@ -153,7 +153,7 @@ class ModelsTestCase(IhatemoneyTestCase):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
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 = models.Person.query.get_by_name(name="zorglub", project=project)
|
||||||
zorglub_bills = models.Bill.query.options(
|
zorglub_bills = models.Bill.query.options(
|
||||||
orm.subqueryload(models.Bill.owers)
|
orm.subqueryload(models.Bill.owers)
|
||||||
|
|
|
@ -13,7 +13,6 @@ from functools import wraps
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from dateutil.parser import parse
|
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from flask import (
|
from flask import (
|
||||||
Blueprint,
|
Blueprint,
|
||||||
|
@ -454,7 +453,7 @@ def import_project():
|
||||||
elif data.mimetype == "text/csv":
|
elif data.mimetype == "text/csv":
|
||||||
try:
|
try:
|
||||||
bills = csv2list_of_dicts(data)
|
bills = csv2list_of_dicts(data)
|
||||||
except Exception as b:
|
except Exception:
|
||||||
raise ValueError(_("Unable to parse CSV"))
|
raise ValueError(_("Unable to parse CSV"))
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unsupported file type")
|
raise ValueError("Unsupported file type")
|
||||||
|
@ -484,7 +483,8 @@ def import_project():
|
||||||
if len(currencies - {CurrencyConverter.no_currency}) >= 2:
|
if len(currencies - {CurrencyConverter.no_currency}) >= 2:
|
||||||
raise ValueError(
|
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)
|
# Strip currency from bills (since it's the same for every bill)
|
||||||
|
|
Loading…
Reference in a new issue