def test_get_payload(random_path, populated_database):
    device_id = mod.serialized_device_id(random_path)
    test_data, databases = populated_database
    sorted_data = sorted(test_data, key=lambda x: x.timestamp)
    expected_stream = b''.join(bytes(d.payload) for d in sorted_data)
    ids, payload = mod.get_payload(databases.librarian,
                                   random_path,
                                   limit=None)
    assert len(list(ids)) == len(test_data)
    assert payload == device_id + expected_stream
def test_get_payload_empty(random_path, databases):
    ids, payload = mod.get_payload(databases.librarian,
                                   random_path,
                                   limit=None)
    assert ids == []
    assert payload == b''