示例#1
0
    def test_two_bans_with_reason(self):
        # GIVEN
        when(self.console).time().thenReturn(0)
        player1 = Client(console=self.console, guid='player1GUID', name="P1")
        player1.save()
        penalty1 = ClientBan(clientId=player1.id,
                             timeExpire=-1,
                             adminId=0,
                             reason="test reason")

        player2 = Client(console=self.console, guid='player2GUID', name="P2")
        player2.save()
        penalty2 = ClientTempBan(clientId=player2.id,
                                 timeExpire=self.console.time() + 60 * 2,
                                 adminId=0,
                                 reason="test reason f00")

        when(self.console.storage).getLastPenalties(types=whatever(),
                                                    num=whatever()).thenReturn(
                                                        [penalty1, penalty2])
        # WHEN
        self.lastbans()
        # THEN
        self.mock_command.sayLoudOrPM.assert_has_calls([
            call(self.player, u'^2@1^7 P1^7^7 (Perm) test reason'),
            call(self.player,
                 u'^2@2^7 P2^7^7 (2 minutes remaining) test reason f00'),
        ])
示例#2
0
 def test_one_ban_with_reason(self):
     # GIVEN
     player1 = Client(console=self.console, guid='BillGUID', name="Bill")
     player1.save()
     penalty1 = ClientBan(clientId=player1.id, timeExpire=-1, adminId=0, reason="test reason")
     when(self.console.storage).getLastPenalties(types=whatever(), num=whatever()).thenReturn([penalty1])
     # WHEN
     self.lastbans()
     # THEN
     self.mock_command.sayLoudOrPM.assert_called_once_with(self.player, u'^2@1^7 Bill^7^7 (Perm) test reason')
示例#3
0
 def test_one_ban(self):
     # GIVEN
     player1 = Client(console=self.console, guid='BillGUID', name="Bill")
     player1.save()
     penalty1 = ClientBan(clientId=player1.id, timeExpire=-1, adminId=0)
     when(self.console.storage).getLastPenalties(types=whatever(),
                                                 num=whatever()).thenReturn(
                                                     [penalty1])
     # WHEN
     self.lastbans()
     # THEN
     self.mock_command.sayLoudOrPM.assert_called_once_with(
         self.player, u'^2@1^7 Bill^7^7 (Perm)')
示例#4
0
    def test_two_bans_with_reason(self):
        # GIVEN
        when(self.console).time().thenReturn(0)
        player1 = Client(console=self.console, guid='player1GUID', name="P1")
        player1.save()
        penalty1 = ClientBan(clientId=player1.id, timeExpire=-1, adminId=0, reason="test reason")

        player2 = Client(console=self.console, guid='player2GUID', name="P2")
        player2.save()
        penalty2 = ClientTempBan(clientId=player2.id, timeExpire=self.console.time() + 60*2, adminId=0, reason="test reason f00")

        when(self.console.storage).getLastPenalties(types=whatever(), num=whatever()).thenReturn([penalty1, penalty2])
        # WHEN
        self.lastbans()
        # THEN
        self.mock_command.sayLoudOrPM.assert_has_calls([
            call(self.player, u'^2@1^7 P1^7^7 (Perm) test reason'),
            call(self.player, u'^2@2^7 P2^7^7 (2 minutes remaining) test reason f00'),
        ])