aboutsummaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/test.py b/test.py
index 56f6949..b26fc89 100755
--- a/test.py
+++ b/test.py
@@ -708,6 +708,85 @@ New Balance: bob -> 5.00 charlie
#TODO: tanken, transfer, cars pay
+class TestListChangesCmd(unittest.TestCase):
+
+ def setUp(self):
+ reset_state("test/state.json_3users")
+
+ def test_list_changes_unregistered(self):
+ res = run_bot(self, "+4971576357", "!list-changes")
+ self.assertEqual(res.stdout, 'ERROR: you must register first')
+
+ def test_list_changes_single_change(self):
+ run_bot(self, num[alice], f"!schieb {bob} 10")
+ res = run_bot(self, num[alice], "!list-changes")
+ msg = \
+"""Changes from alice 1-1
+Change 1:
+!schieb bob 10
+alice <- 10.00 bob
+"""
+ self.assertEqual(res.stdout, msg)
+
+ def test_list_changes_single_change_invalid_amount(self):
+ run_bot(self, num[alice], f"!schieb {bob} 10")
+ res = run_bot(self, num[alice], "!list-changes foo")
+ msg = \
+"""ERROR: the amount of changes to list must be a number"""
+ self.assertEqual(res.stdout, msg)
+
+ def test_list_changes_single_change_invalid_offset(self):
+ run_bot(self, num[alice], f"!schieb {bob} 10")
+ res = run_bot(self, num[alice], "!list-changes 1 foo")
+ msg = \
+"""ERROR: the first change to list must be a number"""
+ self.assertEqual(res.stdout, msg)
+
+ res = run_bot(self, num[alice], "!list-changes 1 20")
+ msg = \
+"""ERROR: the first change to list is bigger than there are changes"""
+ self.assertEqual(res.stdout, msg)
+
+ def test_list_changes_two_changes(self):
+ run_bot(self, num[alice], f"!schieb {bob} 10")
+ run_bot(self, num[alice], f"!zieh {charlie} 5")
+ res = run_bot(self, num[alice], "!list-changes")
+ msg = \
+"""Changes from alice 1-2
+Change 1:
+!schieb bob 10
+alice <- 10.00 bob
+Change 2:
+!zieh charlie 5
+alice -> 5.00 charlie
+"""
+ self.assertEqual(res.stdout, msg)
+
+ def test_list_changes_one_of_two(self):
+ run_bot(self, num[alice], f"!schieb {bob} 10")
+ run_bot(self, num[alice], f"!zieh {charlie} 5")
+ res = run_bot(self, num[alice], "!list-changes 1")
+ msg = \
+"""Changes from alice 2-2
+Change 2:
+!zieh charlie 5
+alice -> 5.00 charlie
+"""
+ self.assertEqual(res.stdout, msg)
+
+ def test_list_changes_only_second(self):
+ run_bot(self, num[alice], f"!schieb {bob} 10")
+ run_bot(self, num[alice], f"!zieh {charlie} 5")
+ run_bot(self, num[alice], f"!split 9 {bob} {charlie}")
+ res = run_bot(self, num[alice], "!list-changes 1 2")
+ msg = \
+"""Changes from alice 2-2
+Change 2:
+!zieh charlie 5
+alice -> 5.00 charlie
+"""
+ self.assertEqual(res.stdout, msg)
+
class TestFuckCmd(unittest.TestCase):
def setUp(self):