aboutsummaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py67
1 files changed, 65 insertions, 2 deletions
diff --git a/test.py b/test.py
index 81375fc..b74fe7a 100755
--- a/test.py
+++ b/test.py
@@ -249,6 +249,33 @@ class TestTransactionCmd(unittest.TestCase):
res.stdout,
'ERROR: you can not transfer money to or from yourself')
+ def test_transactions_with_multiple_recipients(self):
+ for cmds in [('schieb', 'zieh'), ('gib', 'nimm')]:
+ res = run_bot(self, num[charlie], f'!{cmds[0]} 5 {alice} {bob}')
+ self.assertEqual(res.stdout, \
+"""-> alice 5.00
+-> bob 5.00
+New Balance:
+charlie:
+\t<- alice 5.00
+\t<- bob 5.00
+\tBalance: 10.00""")
+
+ res = run_bot(self, num[charlie], f'!{cmds[1]} 5 {alice} {bob}')
+ self.assertEqual(res.stdout, \
+"""<- alice 5.00
+<- bob 5.00
+New Balance:
+charlie:
+\tAll fine :)""")
+
+ def test_invalid_transactions_with_multiple_recipients(self):
+ res = run_bot(self, num[charlie], f'!schieb {alice} 5 {bob}')
+ self.assertEqual(res.stdout, 'ERROR: amount must be a positive number')
+
+ res = run_bot(self, num[charlie], f'!zieh 5 5 {bob}')
+ self.assertEqual(res.stdout, 'ERROR: recipient "5" not known')
+
class TestSumCmd(unittest.TestCase):
@@ -501,6 +528,44 @@ class TestAlias(unittest.TestCase):
self.assertEqual(res.stdout,
'ERROR: Alias "all" is already registered')
+
+class TestAliasUsage(unittest.TestCase):
+
+ def setUp(self):
+ reset_state("test/state_3users_1alias.json")
+
+ def test_schieb_alias(self):
+ expected = \
+"""-> alice 5.00
+-> bob 5.00
+New Balance:
+charlie:
+\t<- alice 5.00
+\t<- bob 5.00
+\tBalance: 10.00"""
+
+ for cmd in ['gib', 'schieb']:
+ for args in ['5 alob', 'alob 5']:
+ res = run_bot(self, num[charlie], f'!{cmd} {args}')
+ self.assertEqual(res.stdout, expected)
+ self.setUp()
+
+ def test_zieh_alias(self):
+ expected = \
+"""<- alice 5.00
+<- bob 5.00
+New Balance:
+charlie:
+\t-> alice 5.00
+\t-> bob 5.00
+\tBalance: -10.00"""
+
+ for cmd in ['nimm', 'zieh']:
+ for args in ['5 alob', 'alob 5']:
+ res = run_bot(self, num[charlie], f'!{cmd} {args}')
+ self.assertEqual(res.stdout, expected)
+ self.setUp()
+
def test_split_all(self):
res = run_bot(self, num[alice], "!split 9 all")
self.assertEqual(res.stdout, \
@@ -512,7 +577,6 @@ alice:
\tBalance: 6.00""")
def test_split_alias(self):
- run_bot(self, num[alice], f"!alias alob {alice} {bob}")
res = run_bot(self, num[charlie], "!split 9 alob")
self.assertEqual(res.stdout, \
"""Split 9.00 between 3 -> 3.00 each
@@ -535,7 +599,6 @@ alice:
\tBalance: 6.66""")
def test_tanken_alias(self):
- run_bot(self, num[alice], f"!alias alob {alice} {bob}")
res = run_bot(self, num[charlie], "!tanken 8\n10 alob")
self.assertEqual(res.stdout, \
"""alice: 10km = fuel: 4.00, service charge: 0.00