def stringReceived(self, s): msgType, body = strictSecureDecodeJson(s) if msgType == "Point": self._handleNewCircle(body) elif msgType == "ClearBoard": self.factory.clearBoard(dontTell=(self,))
def test_rejectsTrailingBytes(self): self.assertRaises(StrictDecodeError, lambda: strictSecureDecodeJson('{"a": {}} ')) self.assertRaises(StrictDecodeError, lambda: strictSecureDecodeJson('{"a": {}}\n')) self.assertRaises(StrictDecodeError, lambda: strictSecureDecodeJson('347681x')) self.assertEqual(347681, strictSecureDecodeJson('347681'))
def test_usesSecuredict(self): out = strictSecureDecodeJson('{"a": {}}') self.assertEqual(securedict({"a": securedict()}), out) self.assertTrue(isinstance(out, securedict), type(out)) self.assertTrue(isinstance(out["a"], securedict), type(out))
def test_rejectsNanInf(self): self.assertRaises(StrictDecodeError, lambda: strictSecureDecodeJson('[NaN]')) self.assertRaises(StrictDecodeError, lambda: strictSecureDecodeJson('[Infinity]')) self.assertRaises(StrictDecodeError, lambda: strictSecureDecodeJson('[-Infinity]'))
def stringReceived(self, s): msgType, body = strictSecureDecodeJson(s) if msgType == "SetPreferences": self._setPreferences(body)