chore: add a test for unmarshalling a big endian message (#156)

This commit is contained in:
J. Nick Koston 2022-11-04 19:43:22 +01:00 committed by GitHub
parent 984738c803
commit b3297008bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -545,3 +545,24 @@ def test_unmarshall_large_message():
"org.freedesktop.DBus.Introspectable": {},
"org.freedesktop.DBus.Properties": {},
}
def test_unmarshall_big_endian_message():
"""Test we can unmarshall a big endian message."""
msg = (
b"B\x01\x00\x01\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x82"
b"\x01\x01o\x00\x00\x00\x00\x01/\x00\x00\x00\x00\x00\x00\x00"
b'\x02\x01s\x00\x00\x00\x00"org.freedesktop.DBus.ObjectManag'
b"er\x00\x00\x00\x00\x00\x00\x03\x01s\x00\x00\x00\x00\x11GetManagedOb"
b"jects\x00\x00\x00\x00\x00\x00\x00\x06\x01s\x00\x00\x00\x00\torg."
b"bluez\x00\x00\x00\x00\x00\x00\x00\x08\x01g\x00\x04ussv\x00\x00\x00"
b"\x00\x00\x00\x00\x00\x00\x00*\x00\x00\x00\x03zip\x00"
b"\x00\x00\x00\x07Trusted\x00\x01b\x00\x00\x00\x00\x00\x01"
)
stream = io.BytesIO(msg)
unmarshaller = Unmarshaller(stream)
unmarshaller.unmarshall()
message = unmarshaller.message
unpacked = unpack_variants(message.body)
assert unpacked == [42, "zip", "Trusted", True]