mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Fix unittest for mail contrib update
This commit is contained in:
parent
e09390b02b
commit
5871e64681
2 changed files with 6 additions and 5 deletions
|
|
@ -133,7 +133,7 @@ class CmdMail(default_cmds.MuxCommand):
|
|||
return
|
||||
else:
|
||||
all_mail = self.get_all_mail()
|
||||
mind_max = all_mail.count() - 1
|
||||
mind_max = max(0, all_mail.count() - 1)
|
||||
mind = max(0, min(mind_max, int(self.lhs) - 1))
|
||||
if all_mail[mind]:
|
||||
all_mail[mind].delete()
|
||||
|
|
@ -154,7 +154,7 @@ class CmdMail(default_cmds.MuxCommand):
|
|||
return
|
||||
else:
|
||||
all_mail = self.get_all_mail()
|
||||
mind_max = all_mail.count() - 1
|
||||
mind_max = max(0, all_mail.count() - 1)
|
||||
if "/" in self.rhs:
|
||||
message_number, message = self.rhs.split("/", 1)
|
||||
mind = max(0, min(mind_max, int(message_number) - 1))
|
||||
|
|
@ -193,7 +193,7 @@ class CmdMail(default_cmds.MuxCommand):
|
|||
return
|
||||
else:
|
||||
all_mail = self.get_all_mail()
|
||||
mind_max = all_mail.count() - 1
|
||||
mind_max = max(0, all_mail.count() - 1)
|
||||
mind = max(0, min(mind_max, int(self.lhs) - 1))
|
||||
if all_mail[mind]:
|
||||
old_message = all_mail[mind]
|
||||
|
|
@ -218,9 +218,9 @@ class CmdMail(default_cmds.MuxCommand):
|
|||
self.send_mail(self.search_targets(self.lhslist), subject, body, self.caller)
|
||||
else:
|
||||
all_mail = self.get_all_mail()
|
||||
mind_max = all_mail.count() - 1
|
||||
mind_max = max(0, all_mail.count() - 1)
|
||||
try:
|
||||
mind = max(0, min(mind_max, self.lhs - 1))
|
||||
mind = max(0, min(mind_max, int(self.lhs) - 1))
|
||||
message = all_mail[mind]
|
||||
except (ValueError, IndexError):
|
||||
self.caller.msg("'%s' is not a valid mail id." % self.lhs)
|
||||
|
|
|
|||
|
|
@ -661,6 +661,7 @@ from evennia.contrib import mail
|
|||
class TestMail(CommandTest):
|
||||
def test_mail(self):
|
||||
self.call(mail.CmdMail(), "2", "'2' is not a valid mail id.", caller=self.account)
|
||||
self.call(mail.CmdMail(), "test", "'test' is not a valid mail id.")
|
||||
self.call(mail.CmdMail(), "", "There are no messages in your inbox.", caller=self.account)
|
||||
self.call(mail.CmdMail(), "Char=Message 1", "You have received a new @mail from Char|You sent your message.", caller=self.char1)
|
||||
self.call(mail.CmdMail(), "Char=Message 2", "You sent your message.", caller=self.char2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue