diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2020-09-14 17:52:14 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2020-09-14 17:52:14 +0200 |
| commit | ee17da20fb504838904f0f06857c76f4c17520e2 (patch) | |
| tree | 4726ccc9de45d9263d70526f90fe94f528602acb /test.py | |
| parent | 46e38d1ce0e4d25342b7d0adb3db0f3855d959eb (diff) | |
| download | geldschieberbot-ee17da20fb504838904f0f06857c76f4c17520e2.tar.gz geldschieberbot-ee17da20fb504838904f0f06857c76f4c17520e2.zip | |
support rewinding specific changes
Diffstat (limited to 'test.py')
| -rwxr-xr-x | test.py | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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") |
