aboutsummaryrefslogtreecommitdiff
path: root/ihatemoney/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ihatemoney/tests')
-rw-r--r--ihatemoney/tests/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/ihatemoney/tests/tests.py b/ihatemoney/tests/tests.py
index 9f9d8fa..d29ec62 100644
--- a/ihatemoney/tests/tests.py
+++ b/ihatemoney/tests/tests.py
@@ -621,6 +621,18 @@ class BudgetTestCase(IhatemoneyTestCase):
resp = self.client.get("/raclette/")
self.assertNotIn('extra-info', resp.data.decode('utf-8'))
+ def test_negative_weight(self):
+ self.post_project("raclette")
+
+ # Add one user and edit it to have a negative share
+ self.client.post("/raclette/members/add", data={'name': 'alexis'})
+ resp = self.client.post("/raclette/members/1/edit", data={'name': 'alexis', 'weight': -1})
+
+ # An error should be generated, and its weight should still be 1.
+ self.assertIn('<p class="alert alert-danger">', resp.data.decode('utf-8'))
+ self.assertEqual(len(models.Project.query.get('raclette').members), 1)
+ self.assertEqual(models.Project.query.get('raclette').members[0].weight, 1)
+
def test_rounding(self):
self.post_project("raclette")