Example #1
0
    def test_update_decode(self):
        with open(UpdatesTests.DECODE_FILE) as json_file:
            j = json.load(json_file)
        obj = Update.decode(j)

        self.assertEqual(obj.update_id, j[Update.FIELD_UPDATEID])
        self.assertIsInstance(obj.message, Message)
Example #2
0
    def test_update_decode(self):
        with open(UpdatesTests.DECODE_FILE) as json_file:
            j = json.load(json_file)
        obj = Update.decode(j)

        self.assertEqual(obj.update_id, j[Update.FIELD_UPDATEID])
        self.assertIsInstance(obj.message, Message)
Example #3
0
    def _post_handler(self):
        try:
            j = json.loads(request.data)
        except ValueError:
            return make_response('DATA ERROR', 500)

        try:
            update = Update.decode(j)
        except ObjectDecodingException:
            return make_response('DECODE ERROR', 500)

        if self._update_handler(update):
            return make_response('OK', 200)

        return make_response('ERROR', 500)