aboutsummaryrefslogtreecommitdiff
path: root/ihatemoney/tests/tests.py
diff options
context:
space:
mode:
authorAlexis Metaireau <alexis@notmyidea.org>2019-01-03 13:29:56 +0100
committerGitHub <noreply@github.com>2019-01-03 13:29:56 +0100
commitd55b9961704f913312ae17f837f62d1822802ecf (patch)
tree02bc27f0b6ffdaf15a08b651d2953f35356c0148 /ihatemoney/tests/tests.py
parent04adfe4155e1bb37609edfe78ae67b361f51e0cf (diff)
downloadihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.zip
ihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.tar.gz
ihatemoney-mirror-d55b9961704f913312ae17f837f62d1822802ecf.tar.bz2
Do not allow negative weights on users (Fixes #362) (#366)
Diffstat (limited to 'ihatemoney/tests/tests.py')
-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")