1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

Merge pull request #75 from fredericsureau/master

Fix bug #73.
This commit is contained in:
Alexis Metaireau 2012-03-30 17:02:52 -07:00
commit a9d9f1e6fd
2 changed files with 26 additions and 1 deletions

View file

@ -114,7 +114,7 @@ class Person(db.Model):
def has_bills(self):
"""return if the user do have bills or not"""
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()
return bills_as_ower_number != 0 or len(self.bills) != 0

View file

@ -214,6 +214,31 @@ class BudgetTestCase(TestCase):
self.assertEqual(
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):
self.post_project("raclette")
self.login("raclette")