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)
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)
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)
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
def test_zaebal_logovenok(self): assert (self.module.reply(FakeEvent('заебал логовенок ваш')) == True) calls = self.fake_send_message.call_args_list assert (len(calls) == 1)
def test_zaebal_between(self): assert (self.module.reply(FakeEvent('бот уже заебал!')) == True) calls = self.fake_send_message.call_args_list assert (len(calls) == 1)
def test_zaebal(self): assert (self.module.reply(FakeEvent('этот бот заебал уже')) == True) calls = self.fake_send_message.call_args_list assert (len(calls) == 1)
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 ['Аахпахпха', 'Лол'])
def test_appeal_wrong(self): assert (self.module.reply(FakeEvent('шпио, нет')) == False) calls = self.fake_send_message.call_args_list assert (len(calls) == 0)
def test_who(self): assert (self.module.reply(FakeEvent('кто лиля?')) == True) calls = self.fake_send_message.call_args_list assert (len(calls) == 1)
def test_da_not_ending(self): assert (self.module.reply(FakeEvent('всегда!')) == False) self.fake_send_message.assert_not_called()
def test_da_ending(self): assert (self.module.reply(FakeEvent('о да!')) == True) self.fake_send_message.assert_called_with(100, 'Пизда!')
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)
def test_empty_message(self): assert (self.module.reply(FakeEvent('')) == False) self.fake_send_message.assert_not_called()
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])
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')
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])
def test_multiline(self): assert (self.module.reply(FakeEvent('ывы\nваыв\nда')) == True) calls = self.fake_send_message.call_args_list assert (len(calls) == 1)
def test_not_reply_if_not_joseph(self): assert (self.module.reply(FakeEvent('Да', 100500)) == False)