aboutsummaryrefslogtreecommitdiff
path: root/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'test.py')
-rwxr-xr-xtest.py90
1 files changed, 38 insertions, 52 deletions
diff --git a/test.py b/test.py
index 8d44c82..3cf5c8d 100755
--- a/test.py
+++ b/test.py
@@ -111,11 +111,11 @@ class TestRegCmd(unittest.TestCase):
def test_correct_reg(self):
res = run_bot(self, num[alice], "!reg " + alice)
- self.assertEqual(res.stdout, 'Happy geldschiebing {}!'.format(alice))
+ self.assertEqual(res.stdout, f'Happy geldschiebing {alice}!')
def test_double_reg(self):
res = run_bot(self, num[alice], "!reg " + alice)
- self.assertEqual(res.stdout, 'Happy geldschiebing {}!'.format(alice))
+ self.assertEqual(res.stdout, f'Happy geldschiebing {alice}!')
res = run_bot(self, num[alice], "!reg " + alice)
self.assertEqual(res.stdout, 'ERROR: ' + alice + ' already registered')
@@ -134,11 +134,11 @@ class TestRegCmd(unittest.TestCase):
def test_additional_reg(self):
res = run_bot(self, num[alice], "!reg " + alice)
- self.assertEqual(res.stdout, 'Happy geldschiebing {}!'.format(alice))
+ self.assertEqual(res.stdout, f'Happy geldschiebing {alice}!')
res = run_bot(self, num[bob], "!reg " + bob)
- self.assertEqual(res.stdout, 'Happy geldschiebing {}!'.format(bob))
+ self.assertEqual(res.stdout, f'Happy geldschiebing {bob}!')
res = run_bot(self, num[charlie], "!reg " + charlie)
- self.assertEqual(res.stdout, 'Happy geldschiebing {}!'.format(charlie))
+ self.assertEqual(res.stdout, f'Happy geldschiebing {charlie}!')
self.assertTrue(compare_state("test/state_3users.json"))
@@ -154,30 +154,24 @@ class TestTransactionCmd(unittest.TestCase):
def test_correct_schieb(self):
res = run_bot(self, num[alice], "!schieb 10 " + bob)
- self.assertEqual(res.stdout,
- 'New Balance: {} <- 10.00 {}\n'.format(alice, bob))
+ self.assertEqual(res.stdout, f'New Balance: {alice} <- 10.00 {bob}\n')
res = run_bot(self, num[bob], "!schieb 10 " + alice)
- self.assertEqual(res.stdout,
- 'New Balance: {} <- 0.00 {}\n'.format(bob, alice))
+ self.assertEqual(res.stdout, f'New Balance: {bob} <- 0.00 {alice}\n')
def test_correct_gib(self):
res = run_bot(self, num[alice], "!gib 10 " + bob)
- self.assertEqual(res.stdout,
- 'New Balance: {} <- 10.00 {}\n'.format(alice, bob))
+ self.assertEqual(res.stdout, f'New Balance: {alice} <- 10.00 {bob}\n')
res = run_bot(self, num[bob], "!gib 10 " + alice)
- self.assertEqual(res.stdout,
- 'New Balance: {} <- 0.00 {}\n'.format(bob, alice))
+ self.assertEqual(res.stdout, f'New Balance: {bob} <- 0.00 {alice}\n')
def test_correct_amount(self):
res = run_bot(self, num[bob], "!schieb 1.1 " + alice)
- self.assertEqual(res.stdout,
- 'New Balance: {} <- 1.10 {}\n'.format(bob, alice))
+ self.assertEqual(res.stdout, f'New Balance: {bob} <- 1.10 {alice}\n')
res = run_bot(self, num[bob], "!gib 1,1 " + alice)
- self.assertEqual(res.stdout,
- 'New Balance: {} <- 2.20 {}\n'.format(bob, alice))
+ self.assertEqual(res.stdout, f'New Balance: {bob} <- 2.20 {alice}\n')
def test_invalid_amount(self):
res = run_bot(self, num[bob], "!schieb 1b1 " + alice)
@@ -188,17 +182,15 @@ class TestTransactionCmd(unittest.TestCase):
def test_correct_schieb_name_before_amount(self):
res = run_bot(self, num[alice], "!schieb " + bob + " 10")
- self.assertEqual(res.stdout,
- 'New Balance: {} <- 10.00 {}\n'.format(alice, bob))
+ self.assertEqual(res.stdout, f'New Balance: {alice} <- 10.00 {bob}\n')
res = run_bot(self, num[bob], "!schieb " + alice + " 10")
- self.assertEqual(res.stdout,
- 'New Balance: {} <- 0.00 {}\n'.format(bob, alice))
+ self.assertEqual(res.stdout, f'New Balance: {bob} <- 0.00 {alice}\n')
def test_correct_gib_name_before_amount(self):
res = run_bot(self, num[alice], "!gib " + charlie + " 10")
- self.assertEqual(
- res.stdout, 'New Balance: {} <- 10.00 {}\n'.format(alice, charlie))
+ self.assertEqual(res.stdout,
+ f'New Balance: {alice} <- 10.00 {charlie}\n')
res = run_bot(self, num[charlie], "!gib " + alice + " 10")
self.assertEqual(res.stdout,
@@ -206,38 +198,35 @@ class TestTransactionCmd(unittest.TestCase):
def test_correct_nimm(self):
res = run_bot(self, num[alice], "!nimm 10 " + bob)
- self.assertEqual(res.stdout,
- 'New Balance: {} -> 10.00 {}\n'.format(alice, bob))
+ self.assertEqual(res.stdout, f'New Balance: {alice} -> 10.00 {bob}\n')
res = run_bot(self, num[bob], "!nimm 10 " + alice)
- self.assertEqual(res.stdout,
- 'New Balance: {} <- 0.00 {}\n'.format(bob, alice))
+ self.assertEqual(res.stdout, f'New Balance: {bob} <- 0.00 {alice}\n')
def test_correct_zieh_name_before_amount(self):
res = run_bot(self, num[alice], "!zieh " + charlie + " 10")
- self.assertEqual(
- res.stdout, 'New Balance: {} -> 10.00 {}\n'.format(alice, charlie))
+ self.assertEqual(res.stdout,
+ f'New Balance: {alice} -> 10.00 {charlie}\n')
res = run_bot(self, num[charlie], "!zieh " + alice + " 10")
self.assertEqual(res.stdout,
- 'New Balance: {} <- 0.00 {}\n'.format(charlie, alice))
+ f'New Balance: {charlie} <- 0.00 {alice}\n')
def test_transactions_complex(self):
res = run_bot(self, num[alice], "!schieb " + charlie + " 1,1")
self.assertEqual(res.stdout,
- 'New Balance: {} <- 1.10 {}\n'.format(alice, charlie))
+ f'New Balance: {alice} <- 1.10 {charlie}\n')
res = run_bot(self, num[alice], "!zieh " + charlie + " 2.1")
self.assertEqual(res.stdout,
- 'New Balance: {} -> 1.00 {}\n'.format(alice, charlie))
+ f'New Balance: {alice} -> 1.00 {charlie}\n')
res = run_bot(self, num[charlie], "!schieb " + bob + " 42")
self.assertEqual(res.stdout,
- 'New Balance: {} <- 42.00 {}\n'.format(charlie, bob))
+ f'New Balance: {charlie} <- 42.00 {bob}\n')
res = run_bot(self, num[alice], "!zieh " + bob + " 0.01")
- self.assertEqual(res.stdout,
- 'New Balance: {} -> 0.01 {}\n'.format(alice, bob))
+ self.assertEqual(res.stdout, f'New Balance: {alice} -> 0.01 {bob}\n')
compare_state("test/state_transactions1.json")
@@ -270,7 +259,7 @@ class TestSumCmd(unittest.TestCase):
def test_summary_double_user(self):
reset_state("test/state_transactions1.json")
- res = run_bot(self, num[alice], "!sum {} {}".format(alice, bob))
+ res = run_bot(self, num[alice], f"!sum {alice} {bob}")
summary = \
"""Summary:
alice:
@@ -337,14 +326,12 @@ class TestListCmd(unittest.TestCase):
def test_ls(self):
res = run_bot(self, num[alice], "!ls")
- msg = "alice: {}\nbob: {}\ncharlie: {}\n".format(
- num[alice], num[bob], num[charlie])
+ msg = f"alice: {num[alice]}\nbob: {num[bob]}\ncharlie: {num[charlie]}\n"
self.assertEqual(res.stdout, msg)
def test_list(self):
res = run_bot(self, num[bob], "!list")
- msg = "alice: {}\nbob: {}\ncharlie: {}\n".format(
- num[alice], num[bob], num[charlie])
+ msg = f"alice: {num[alice]}\nbob: {num[bob]}\ncharlie: {num[charlie]}\n"
self.assertEqual(res.stdout, msg)
@@ -1001,13 +988,13 @@ Cancelled the weekly cmd "stuff\""""
res = run_bot(self, num[alice], "!fuck")
# There is no new line because the real bot uses two Messages
msg = \
-"""Nothing to rewindRunning weekly command stuff for alice triggered on {}
+f"""Nothing to rewindRunning weekly command stuff for alice triggered on {now.isoformat()}
Split 3.00 between 3 -> 1.00 each
New Balance:
alice:
\t<- bob 2.00
\t<- charlie 2.00
-\tBalance: 4.00""".format(now.isoformat())
+\tBalance: 4.00"""
self.assertEqual(res.stdout, msg)
compare_state("test/state.json_schedule_weekly")
@@ -1022,21 +1009,21 @@ alice:
res = run_bot(self, num[alice], "!fuck")
# There is no new line because the real bot uses two Messages
+ last_week = now - timedelta(7)
msg = \
-"""Nothing to rewindRunning weekly command stuff for alice triggered on {}
+f"""Nothing to rewindRunning weekly command stuff for alice triggered on {last_week.isoformat()}
Split 3.00 between 3 -> 1.00 each
New Balance:
alice:
\t<- bob 2.00
\t<- charlie 2.00
-\tBalance: 4.00Running weekly command stuff for alice triggered on {}
+\tBalance: 4.00Running weekly command stuff for alice triggered on {now.isoformat()}
Split 3.00 between 3 -> 1.00 each
New Balance:
alice:
\t<- bob 3.00
\t<- charlie 3.00
-\tBalance: 6.00""".format((now - timedelta(7)).isoformat(),
- now.isoformat())
+\tBalance: 6.00"""
self.assertEqual(res.stdout, msg)
os.remove("test/state.json_schedule_weekly")
@@ -1079,13 +1066,13 @@ Cancelled the monthly cmd "stuff\""""
res = run_bot(self, num[alice], "!fuck")
# There is no new line because the real bot uses two Messages
msg = \
-"""Nothing to rewindRunning monthly command stuff for alice triggered on {}
+f"""Nothing to rewindRunning monthly command stuff for alice triggered on {now.isoformat()}
Split 3.00 between 3 -> 1.00 each
New Balance:
alice:
\t<- bob 2.00
\t<- charlie 2.00
-\tBalance: 4.00""".format(now.isoformat())
+\tBalance: 4.00"""
self.assertEqual(res.stdout, msg)
compare_state("test/state.json_schedule_monthly")
@@ -1106,20 +1093,19 @@ alice:
res = run_bot(self, num[alice], "!fuck")
# There is no new line because the real bot uses to Messages
msg = \
-"""Nothing to rewindRunning monthly command stuff for alice triggered on {}
+f"""Nothing to rewindRunning monthly command stuff for alice triggered on {one_month_ago.isoformat()}
Split 3.00 between 3 -> 1.00 each
New Balance:
alice:
\t<- bob 2.00
\t<- charlie 2.00
-\tBalance: 4.00Running monthly command stuff for alice triggered on {}
+\tBalance: 4.00Running monthly command stuff for alice triggered on {now.isoformat()}
Split 3.00 between 3 -> 1.00 each
New Balance:
alice:
\t<- bob 3.00
\t<- charlie 3.00
-\tBalance: 6.00""".format(one_month_ago.isoformat(),
- now.isoformat())
+\tBalance: 6.00"""
self.assertEqual(res.stdout, msg)
os.remove("test/state.json_schedule_monthly")