Exemplo n.º 1
0
Arquivo: chat.py Projeto: sbuss/qotr
 def on_message(self, message):
     try:
         message = Message.from_json(message)
         message.sender = self
         getattr(self, 'handle_' + message.kind.name)(message)
     except ValueError:
         self.respond_with_error("Invalid message format.")
     except KeyError:
         self.respond_with_error("Invalid message kind.")
Exemplo n.º 2
0
 def on_message(self, message):
     try:
         message = Message.from_json(message)
         message.sender = self
         getattr(self, 'handle_' + message.kind.name)(message)
     except ValueError:
         self.respond_with_error("Invalid message format.")
     except KeyError:
         self.respond_with_error("Invalid message kind.")
Exemplo n.º 3
0
 def test_json(self):
     obj = m("chat", "test")
     message = Message.from_json(json.dumps(obj))
     self.assertEqual(obj, message.as_json())
Exemplo n.º 4
0
 def test_json(self):
     obj = m("chat", "test")
     message = Message.from_json(json.dumps(obj))
     self.assertEqual(obj, message.as_json())