def test_decode(mock_possible_tricks, configuration_with_data):
    # Setup
    data, expected = configuration_with_data

    # Run
    decoder = BitPackDecoder(data)
    result = TrickLevelConfiguration.bit_pack_unpack(decoder, {})

    # Assert
    assert result == expected
def test_decode(configuration_with_data):
    # Setup
    data, expected = configuration_with_data

    # Run
    decoder = BitPackDecoder(data)
    result = TrickLevelConfiguration.bit_pack_unpack(decoder, {
        "reference":
        TrickLevelConfiguration(False, {}, RandovaniaGame.PRIME2),
    })

    # Assert
    assert result == expected
def test_encode_no_tricks_are_removed():
    from_json = TrickLevelConfiguration.from_json({
        "minimal_logic": False,
        "specific_levels": {
            "Dash": "no-tricks"
        }
    })

    encoded = bitpacking._pack_encode_results([
        (value_argument, value_format)
        for value_argument, value_format in from_json.bit_pack_encode({})
    ])

    assert encoded == b'\x00\x00\x00\x00'

    decoder = BitPackDecoder(encoded)
    decoded = TrickLevelConfiguration.bit_pack_unpack(decoder, {})

    assert decoded.specific_levels == {}
def test_encode_no_tricks_are_removed():
    from_json = TrickLevelConfiguration.from_json(
        {
            "minimal_logic": False,
            "specific_levels": {
                "Dash": "disabled"
            }
        },
        game=RandovaniaGame.PRIME2)

    encoded = bitpacking._pack_encode_results([
        (value_argument, value_format)
        for value_argument, value_format in from_json.bit_pack_encode({})
    ])

    assert encoded == b'\x00\x00\x00\x00'

    decoder = BitPackDecoder(encoded)
    decoded = TrickLevelConfiguration.bit_pack_unpack(decoder, {
        "reference":
        TrickLevelConfiguration(False, {}, RandovaniaGame.PRIME2),
    })

    assert decoded.specific_levels == {}