Beispiel #1
0
def _decode_event(data, content_encoding):
    if isinstance(data, six.binary_type):
        if content_encoding == 'gzip':
            data = decompress_gzip(data)
        elif content_encoding == 'deflate':
            data = decompress_deflate(data)
        elif data[0] != b'{':
            data = decode_and_decompress_data(data)
        else:
            data = decode_data(data)
    if isinstance(data, six.text_type):
        data = safely_load_json_string(data)

    return CanonicalKeyDict(data)
Beispiel #2
0
def _decode_event(data, content_encoding):
    if isinstance(data, six.binary_type):
        if content_encoding == "gzip":
            data = decompress_gzip(data)
        elif content_encoding == "deflate":
            data = decompress_deflate(data)
        elif data[0] != b"{":
            data = decode_and_decompress_data(data)
        else:
            data = decode_data(data)
    if isinstance(data, six.text_type):
        data = safely_load_json_string(data)

    return CanonicalKeyDict(data)
Beispiel #3
0
def test_invalid_data():
    with pytest.raises(APIError):
        decode_data('\x99')
Beispiel #4
0
def test_valid_data():
    data = decode_data('foo')
    assert data == u'foo'
    assert isinstance(data, six.text_type)
Beispiel #5
0
def test_valid_data():
    data = decode_data("foo")
    assert data == u"foo"
    assert isinstance(data, six.text_type)
Beispiel #6
0
def test_invalid_data():
    with pytest.raises(APIError):
        decode_data('\x99')
Beispiel #7
0
def test_valid_data():
    data = decode_data('foo')
    assert data == u'foo'
    assert isinstance(data, six.text_type)