コード例 #1
0
    def test_send_second_time_after_interval(self):
        assert (self.module.reply(FakeEvent('Да',
                                            constants.joseph_id)) == True)

        self.fake_time.return_value = self.module._last_reply_time + self.module.min_interval
        assert (self.module.reply(FakeEvent('Да',
                                            constants.joseph_id)) == False)

        self.fake_time.return_value = self.module._last_reply_time + self.module.min_interval + 1
        assert (self.module.reply(FakeEvent('Да',
                                            constants.joseph_id)) == True)
コード例 #2
0
    def test_not_send_when_session_closed(self):
        assert (self.module.reply(FakeEvent('Да',
                                            constants.joseph_id)) == True)

        self.fake_time.return_value = self.module._last_reply_time + self.module.session_length - 1
        assert (self.module.reply(FakeEvent('Да',
                                            constants.joseph_id)) == True)

        self.fake_time.return_value = self.module._last_reply_time + self.module.session_length
        assert (self.module.reply(FakeEvent('Да',
                                            constants.joseph_id)) == False)
コード例 #3
0
    def test_reply_joseph(self):
        assert (self.module.reply(FakeEvent('Да',
                                            constants.joseph_id)) == True)

        reply = self.fake_send_message.call_args[0][1]
        assert (isinstance(reply, str))
        assert (len(reply) > 0)
コード例 #4
0
 def test_recent_messages(self):
     last_messages = None
     for i in range(100):
         assert (self.module.reply(FakeEvent('Да',
                                             constants.joseph_id)) == True)
         reply = self.fake_send_message.call_args[0][1]
         assert (last_messages != reply)
         last_messages = reply
コード例 #5
0
 def test_zaebal_logovenok(self):
     assert (self.module.reply(FakeEvent('заебал логовенок ваш')) == True)
     calls = self.fake_send_message.call_args_list
     assert (len(calls) == 1)
コード例 #6
0
 def test_zaebal_between(self):
     assert (self.module.reply(FakeEvent('бот уже заебал!')) == True)
     calls = self.fake_send_message.call_args_list
     assert (len(calls) == 1)
コード例 #7
0
 def test_zaebal(self):
     assert (self.module.reply(FakeEvent('этот бот заебал уже')) == True)
     calls = self.fake_send_message.call_args_list
     assert (len(calls) == 1)
コード例 #8
0
 def test_often(self):
     assert (self.module.reply(FakeEvent('ахах')) == True)
     assert (self.module.reply(FakeEvent('ахах')) == False)
     calls = self.fake_send_message.call_args_list
     assert (len(calls) == 1)
     assert (calls[0][0][1] in ['Аахпахпха', 'Лол'])
コード例 #9
0
 def test_appeal_wrong(self):
     assert (self.module.reply(FakeEvent('шпио, нет')) == False)
     calls = self.fake_send_message.call_args_list
     assert (len(calls) == 0)
コード例 #10
0
 def test_who(self):
     assert (self.module.reply(FakeEvent('кто лиля?')) == True)
     calls = self.fake_send_message.call_args_list
     assert (len(calls) == 1)
コード例 #11
0
 def test_da_not_ending(self):
     assert (self.module.reply(FakeEvent('всегда!')) == False)
     self.fake_send_message.assert_not_called()
コード例 #12
0
 def test_da_ending(self):
     assert (self.module.reply(FakeEvent('о да!')) == True)
     self.fake_send_message.assert_called_with(100, 'Пизда!')
コード例 #13
0
 def test_send_several_times_in_session(self):
     assert (self.module.reply(FakeEvent('Да',
                                         constants.joseph_id)) == True)
     assert (self.module.reply(FakeEvent('Да',
                                         constants.joseph_id)) == True)
コード例 #14
0
 def test_empty_message(self):
     assert (self.module.reply(FakeEvent('')) == False)
     self.fake_send_message.assert_not_called()
コード例 #15
0
 def test_mine(self):
     assert (self.module.reply(FakeEvent('наш сервак в майн')) == True)
     calls = self.fake_send_message.call_args_list
     assert (len(calls) == 1)
     assert ('178.33.4.203:26126' in calls[0][0][1])
コード例 #16
0
 def test_F(self):
     assert (self.module.reply(FakeEvent('F')) == True)
     calls = self.fake_send_message.call_args_list
     assert (len(calls) == 1)
     assert (calls[0][0][1] == 'F')
コード例 #17
0
 def test_appeal_net(self):
     assert (self.module.reply(FakeEvent('шпион, нет')) == True)
     calls = self.fake_send_message.call_args_list
     assert (len(calls) == 1)
     assert ('Пидора ответ' in calls[0][0][1])
コード例 #18
0
 def test_multiline(self):
     assert (self.module.reply(FakeEvent('ывы\nваыв\nда')) == True)
     calls = self.fake_send_message.call_args_list
     assert (len(calls) == 1)
コード例 #19
0
 def test_not_reply_if_not_joseph(self):
     assert (self.module.reply(FakeEvent('Да', 100500)) == False)