Ejemplo n.º 1
0
    def test_accept(self):
        """Accept an callback."""
        self.call(CmdCallback(), "/add here = time 8:00", caller=self.char2)
        editor = self.char2.ndb._eveditor
        self.assertIsNotNone(editor)

        # Edit the callback
        editor.update_buffer(
            dedent("""
            room.msg_contents("It's 8 PM, everybody up!")
        """.strip("\n")))
        editor.save_buffer()
        editor.quit()
        callback = self.room1.callbacks.get("time")[0]
        self.assertEqual(callback.valid, False)

        # chars shouldn't be allowed to the callback
        self.call(CmdCallback(), "/accept here = time 1", caller=self.char2)
        callback = self.room1.callbacks.get("time")[0]
        self.assertEqual(callback.valid, False)

        # char1 will accept the callback
        self.call(CmdCallback(), "/accept here = time 1")
        callback = self.room1.callbacks.get("time")[0]
        self.assertEqual(callback.valid, True)
Ejemplo n.º 2
0
    def test_lock(self):
        """Test the lock of multiple editing."""
        self.call(CmdCallback(), "/add here = time 8:00", caller=self.char2)
        self.assertIsNotNone(self.char2.ndb._eveditor)

        # Now ask char1 to edit
        line = self.call(CmdCallback(), "/edit here = time 1")
        self.assertIsNone(self.char1.ndb._eveditor)

        # Try to delete this callback while char2 is editing it
        line = self.call(CmdCallback(), "/del here = time 1")
Ejemplo n.º 3
0
    def test_del(self):
        """Add and remove an callback."""
        self.handler.add_callback(self.exit, "traverse", "pass", author=self.char1, valid=True)

        # Try to delete the callback
        # char2 shouldn't be allowed to do so (that's not HIS callback)
        self.call(CmdCallback(), "/del out = traverse 1", caller=self.char2)
        self.assertTrue(len(self.handler.get_callbacks(self.exit).get("traverse", [])) == 1)

        # Now, char1 should be allowed to delete it
        self.call(CmdCallback(), "/del out = traverse 1")
        self.assertTrue(len(self.handler.get_callbacks(self.exit).get("traverse", [])) == 0)
Ejemplo n.º 4
0
    def test_add(self):
        """Test to add an callback."""
        self.call(CmdCallback(), "/add out = traverse")
        editor = self.char1.ndb._eveditor
        self.assertIsNotNone(editor)

        # Edit the callback
        editor.update_buffer(
            dedent(
                """
            if character.key == "one":
                character.msg("You can pass.")
            else:
                character.msg("You can't pass.")
                deny()
        """.strip(
                    "\n"
                )
            )
        )
        editor.save_buffer()
        editor.quit()
        callback = self.exit.callbacks.get("traverse")[0]
        self.assertEqual(callback.author, self.char1)
        self.assertEqual(callback.valid, True)
        self.assertTrue(len(callback.code) > 0)

        # We're going to try the same thing but with char2
        # char2 being a player for our test, the callback won't be validated.
        self.call(CmdCallback(), "/add out = traverse", caller=self.char2)
        editor = self.char2.ndb._eveditor
        self.assertIsNotNone(editor)

        # Edit the callback
        editor.update_buffer(
            dedent(
                """
            character.msg("No way.")
        """.strip(
                    "\n"
                )
            )
        )
        editor.save_buffer()
        editor.quit()
        callback = self.exit.callbacks.get("traverse")[1]
        self.assertEqual(callback.author, self.char2)
        self.assertEqual(callback.valid, False)
        self.assertTrue(len(callback.code) > 0)
Ejemplo n.º 5
0
 def at_cmdset_creation(self):
     """
     Populates the cmdset
     """
     # For ingame python, I'm commenting out the line below and
     # using the next 'super' command.
     #
     # super().at_cmdset_creation()
     #
     # any commands you add below will overload the default ones.
     #
     super(CharacterCmdSet, self).at_cmdset_creation()
     self.add(CmdCallback())
     self.add(make_latin_noun.CmdMakeLatinObject())
     self.add(make_latin_noun.CmdMakeLatinCharacter())
     self.add(make_latin_noun.CmdMakeLatinRoom())
     self.add(latin_commands.CmdLook())
     # Using new Clothing inventory command
     # self.add(latin_commands.CmdInventory())
     self.add(latin_commands.CmdGet())
     self.add(latin_commands.CmdDrop())
     self.add(latin_commands.CmdGive())
     self.add(ClothedCharacterCmdSet())
     self.add(latin_commands.CmdSay())
     self.add(command.CmdNPC())
     self.add(latin_commands.CmdPut())
     self.add(latin_commands.CmdGetOut())
     self.add(latin_commands.CmdLookIn())
     self.add(latin_commands.CmdHold())
     self.add(latin_commands.CmdStats())
     self.add(tb_basic.BattleCmdSet())
Ejemplo n.º 6
0
    def at_cmdset_creation(self):
        """
        Populates the cmdset
        """
        super(CharacterCmdSet, self).at_cmdset_creation()
        self.add(CmdCallback())
        self.add(CmdEnter())
        self.add(CmdDrive())
        self.add(CmdDrop())
        self.add(CmdEquipment())
        self.add(CmdEmpty())
        self.add(CmdGet())
        self.add(CmdHold())
        self.add(CmdInventory())
        self.add(CmdRemove())
        self.add(CmdWear())
        self.add(CmdApp())
        self.add(CmdBuildingMenu())
        self.add(CmdEdit())
        self.add(CmdNew())
        self.add(CmdHelp())
        self.add(CmdLeave())
        self.add(CmdStartRoad())
        self.add(CmdUse())
        self.add(CmdAnswer())
        self.add(CmdLog())

        # Channel commands
        self.add(CmdChannel())
        self.add(CmdConnect())
        self.add(CmdDisconnect())
Ejemplo n.º 7
0
    def test_list(self):
        """Test listing callbacks with different rights."""
        table = self.call(CmdCallback(), "out")
        lines = table.splitlines()[3:-1]
        self.assertNotEqual(lines, [])

        # Check that the second column only contains 0 (0) (no callback yet)
        for line in lines:
            cols = line.split("|")
            self.assertIn(cols[2].strip(), ("0 (0)", ""))

        # Add some callback
        self.handler.add_callback(self.exit,
                                  "traverse",
                                  "pass",
                                  author=self.char1,
                                  valid=True)

        # Try to obtain more details on a specific callback on exit
        table = self.call(CmdCallback(), "out = traverse")
        lines = table.splitlines()[3:-1]
        self.assertEqual(len(lines), 1)
        line = lines[0]
        cols = line.split("|")
        self.assertIn(cols[1].strip(), ("1", ""))
        self.assertIn(cols[2].strip(), (str(self.char1), ""))
        self.assertIn(cols[-1].strip(), ("Yes", "No", ""))

        # Run the same command with char2
        # char2 shouldn't see the last column (Valid)
        table = self.call(CmdCallback(), "out = traverse", caller=self.char2)
        lines = table.splitlines()[3:-1]
        self.assertEqual(len(lines), 1)
        line = lines[0]
        cols = line.split("|")
        self.assertEqual(cols[1].strip(), "1")
        self.assertNotIn(cols[-1].strip(), ("Yes", "No"))

        # In any case, display the callback
        # The last line should be "pass" (the callback code)
        details = self.call(CmdCallback(), "out = traverse 1")
        self.assertEqual(details.splitlines()[-1], "pass")
Ejemplo n.º 8
0
 def at_cmdset_creation(self):
     """
     Populates the cmdset
     """
     super(CharacterCmdSet, self).at_cmdset_creation()
     #
     # any commands you add below will overload the default ones.
     #
     self.add(CmdEcho())
     self.add(CmdCallback())
     self.add(CmdTestMenu())
Ejemplo n.º 9
0
 def at_cmdset_creation(self):
     """
     Populates the cmdset
     """
     super().at_cmdset_creation()
     #
     # any commands you add below will overload the default ones.
     #
     # new commandsets
     #
     self.add(IussaLatīnaCmdSet())
     self.add(VestītaPersōnaCmdSet())
     self.add(IussaAdministrātōrumCmdSet())
     self.add(Tempus())
     #
     # For combat
     #
     self.add(BattleCmdSet())
     #
     # For ingame_python
     #
     self.add(CmdCallback())
Ejemplo n.º 10
0
 def at_cmdset_creation(self):
     """
     Populates the cmdset
     """
     super().at_cmdset_creation()
     self.add(CmdCallback())