mirror of
https://github.com/YunoHost-Apps/ihatemoney_ynh.git
synced 2024-09-03 19:26:15 +02:00
commit
a9d9f1e6fd
2 changed files with 26 additions and 1 deletions
|
@ -114,7 +114,7 @@ class Person(db.Model):
|
||||||
def has_bills(self):
|
def has_bills(self):
|
||||||
"""return if the user do have bills or not"""
|
"""return if the user do have bills or not"""
|
||||||
bills_as_ower_number = db.session.query(billowers)\
|
bills_as_ower_number = db.session.query(billowers)\
|
||||||
.filter(billowers.columns.get("bill_id") == self.id)\
|
.filter(billowers.columns.get("person_id") == self.id)\
|
||||||
.count()
|
.count()
|
||||||
return bills_as_ower_number != 0 or len(self.bills) != 0
|
return bills_as_ower_number != 0 or len(self.bills) != 0
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,31 @@ class BudgetTestCase(TestCase):
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
len(models.Project.query.get("randomid").active_members), 1)
|
len(models.Project.query.get("randomid").active_members), 1)
|
||||||
|
|
||||||
|
def test_person_model(self):
|
||||||
|
self.post_project("raclette")
|
||||||
|
self.login("raclette")
|
||||||
|
|
||||||
|
# adds a member to this project
|
||||||
|
self.app.post("/raclette/members/add", data={'name': 'alexis' })
|
||||||
|
alexis = models.Project.query.get("raclette").members[-1]
|
||||||
|
|
||||||
|
# should not have any bills
|
||||||
|
self.assertFalse(alexis.has_bills())
|
||||||
|
|
||||||
|
# bound him to a bill
|
||||||
|
self.app.post("/raclette/add", data={
|
||||||
|
'date': '2011-08-10',
|
||||||
|
'what': u'fromage à raclette',
|
||||||
|
'payer': alexis.id,
|
||||||
|
'payed_for': [alexis.id,],
|
||||||
|
'amount': '25',
|
||||||
|
})
|
||||||
|
|
||||||
|
# should have a bill now
|
||||||
|
alexis = models.Project.query.get("raclette").members[-1]
|
||||||
|
self.assertTrue(alexis.has_bills())
|
||||||
|
|
||||||
|
|
||||||
def test_member_delete_method(self):
|
def test_member_delete_method(self):
|
||||||
self.post_project("raclette")
|
self.post_project("raclette")
|
||||||
self.login("raclette")
|
self.login("raclette")
|
||||||
|
|
Loading…
Reference in a new issue