def test_add_empty_msg(self): ChatLog.append("foo") ChatLog.append("") ChatLog.append("bar") self.assertEqual(ChatLog.read(), "foo\nbar")
def test_add_newline(self): ChatLog.append("foo") ChatLog.append("\n") ChatLog.append("bar") self.assertEqual(ChatLog.read(), "foo\nbar")
def test_read_empty_log(self): self.assertEqual(ChatLog.read(), "")
def test_read_from_chat(self): ChatLog.log = collections.deque(["foo", "bar"]) self.assertEqual(ChatLog.read(), "foo\nbar")
def test_append_to_chat(self): for i in range(10): ChatLog.append(self.testString + str(i)) self.assertEqual(ChatLog.read(), "test5\ntest6\ntest7\ntest8\ntest9")
def handle_event(json): ChatLog.append(json['msg']) emit("responce", json['msg'], broadcast=True)
def handle_new_connection(json): emit("connectResponce", ChatLog.read())