aboutsummaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/test.py b/test.py
index 4d05bd6..17194fb 100755
--- a/test.py
+++ b/test.py
@@ -800,6 +800,16 @@ class TestFuckCmd(unittest.TestCase):
res = run_bot(self, num[alice], "!fuck")
self.assertEqual(res.stdout, 'Nothing to rewind')
+ def test_fuck_invalid_change(self):
+ run_bot(self, num[alice], f"!schieb {bob} 10")
+ res = run_bot(self, num[alice], f"!fuck foo")
+ msg = "ERROR: change to rewind must be a number"
+ self.assertEqual(res.stdout, msg)
+
+ res = run_bot(self, num[alice], f"!fuck 20")
+ msg = "ERROR: change to rewind is bigger than there are changes"
+ self.assertEqual(res.stdout, msg)
+
def test_fuck_transaction(self):
for cmd in ["fuck", "undo", "rewind"]:
run_bot(self, num[alice], f"!schieb {bob} 10")
@@ -813,6 +823,33 @@ alice <- 10.00 bob
self.assertEqual(res.stdout, msg)
compare_state("test/state.json_3users")
+ def test_rewind_first(self):
+ run_bot(self, num[alice], f"!split 3 {bob} {charlie}")
+ run_bot(self, num[alice], f"!schieb {bob} 10")
+ run_bot(self, num[alice], f"!nimm {charlie} 10")
+ res = run_bot(self, num[alice], f"!fuck 1")
+ msg = ""\
+"""alice: sorry I fucked up!
+Rewinding:
+!split 3 bob charlie
+alice <- 1.00 bob
+alice <- 1.00 charlie
+"""
+ self.assertEqual(res.stdout, msg)
+
+ def test_rewind_second(self):
+ run_bot(self, num[alice], f"!split 10 {bob} {charlie}")
+ run_bot(self, num[alice], f"!schieb {bob} 10")
+ run_bot(self, num[alice], f"!nimm {charlie} 10")
+ res = run_bot(self, num[alice], f"!fuck 2")
+ msg = ""\
+"""alice: sorry I fucked up!
+Rewinding:
+!schieb bob 10
+alice <- 10.00 bob
+"""
+ self.assertEqual(res.stdout, msg)
+
def test_fuck_split(self):
run_bot(self, num[alice], "!split 3 bob charlie")
res = run_bot(self, num[alice], "!fuck")