예제 #1
0
def test_write_value_cmd_basic(input_data):
    """ Basic test with input data in format: list """
    cmd = CmdWriteData(data=input_data)

    cmd.num_bytes = 1
    assert cmd._header.param == 1
    cmd.num_bytes = 2
    assert cmd._header.param == 2
    cmd.num_bytes = 4
    assert cmd._header.param == 4

    cmd.ops = EnumWriteOps.CLEAR_BITMASK
    assert cmd._header.param == 20

    assert "CmdWriteData" in repr(cmd)
예제 #2
0
def test_invalid_cmd_write_data():
    cmd = CmdWriteData()
    with pytest.raises(SPSDKError):
        cmd.num_bytes = 16
    with pytest.raises(SPSDKError):
        cmd.ops = 10
    with pytest.raises(SPSDKError):
        cmd = CmdWriteData(numbytes=8)
    with pytest.raises(SPSDKError):
        cmd = CmdWriteData(ops=9)
    cmd = CmdWriteData()
    with pytest.raises(SPSDKError):
        cmd.append(address=0xFFFFFFFFF, value=0)
    with pytest.raises(SPSDKError):
        cmd.append(address=0xFFFFFFFF, value=0xFFFFFFFFF)
    cmd.append(5, 6)
    cmd.append(7, 8)
    with pytest.raises(SPSDKError):
        cmd.pop(3)