import unittest from munch import Munch from mosfet.commands import Commands class FakeChat: def __init__(self): self.sent = [] def set_handler(self, handler): self.handler = handler def send(self, text): self.sent.append(text) class FakeGame: def __init__(self): self.dump_result = 2 self.drop_result = True self.dump_item = None def drop_stack(self): return self.drop_result def start_dump(self, item_id): self.dump_item = item_id return self.dump_result class TestInventoryCommands(unittest.TestCase): def setUp(self): self.chat = FakeChat() self.game = FakeGame() self.commands = Commands(Munch( name='mosfet1', chat=self.chat, game=self.game)) def test_drop_command_is_enabled_for_bot(self): self.commands.handle_chat(('CHAT', 'tester', 'mosfet1: 1drop')) self.assertEqual(self.chat.sent, ['ok']) def test_dump_command_starts_dump_for_item_id(self): self.commands.handle_chat(('CHAT', 'tester', 'mosfet1: 1dump 62')) self.assertEqual(self.game.dump_item, 62) self.assertEqual(self.chat.sent, ['ok']) if __name__ == '__main__': unittest.main()