def test_message_send_manual(self): room= roomexist('global') time_stamp = datetime.now() len_now = len(ChatMessage.objects.all()) msg = ChatMessage(content='sss', author=self.chat_user, dest_room=room, time_stamp=time_stamp, mess_type = "normal", comand = "normal") msg.save() len_after = len(ChatMessage.objects.all()) self.assertEqual(len_now, len_after - 1)
def test_message_send_manual(self): room= roomexist('global') timeStamp = datetime.now() len_now = len(ChatMessage.objects.all()) msg = ChatMessage(content='sss', author=self.chat_user, destRoom=room, timeStamp=timeStamp, messType = "normal", comand = "normal") msg.save() len_after = len(ChatMessage.objects.all()) self.assertEqual(len_now, len_after - 1)
def test_global_log(self): for i in range(10): message_content = 'Hello' + str(i) self.client.post("/chat/chat_m/", {'opcode':'message','room': 'global','msg': message_content, 'time':self.time_stamp}) log = self.client.get("/chat/log/") room = roomexist('global') all_message = ChatMessage.objects.filter(dest_room=room) all_message = all_message[len(all_message)-50:] if len(all_message) > 50 else all_message self.assertEqual(len(log.content), len(all_message))
def test_global_log(self): for i in range(10): message_content = 'Hello' + str(i) self.client.post("/chat/chat_m/", {'opcode':'message','room': 'global','msg': message_content}) log = self.client.get("/chat/log/") room = roomexist('global') all_message = ChatMessage.objects.filter(destRoom=room) all_message = all_message[len(all_message)-50:] if len(all_message) > 50 else all_message self.assertEqual(len(log.content), len(all_message))