def test_sdp_hab_locked(): """Test send data returns TRUE if HAB locked""" sdp = SDP(VirtualDeviceHabLocked()) assert sdp.is_opened assert sdp._send_data(CmdPacket(0, 0, 0, 0), b'') assert sdp.status_code == StatusCode.HAB_IS_LOCKED assert sdp.response_value == ResponseValue.LOCKED
def test_sdp_hab_locked(): """Test send data returns TRUE if HAB locked""" sdp = SDP( VirtualDevice(respond_sequence=[ CmdResponse(True, pack('>I', ResponseValue.LOCKED)), CmdResponse(True, pack('>I', ResponseValue.HAB_SUCCESS)) ])) assert sdp.is_opened assert sdp._send_data(CmdPacket(0, 0, 0, 0), b'') assert sdp.status_code == StatusCode.HAB_IS_LOCKED assert sdp.response_value == ResponseValue.LOCKED
def test_sdp_send_data_errors(): error_response = [ CmdResponse(True, pack('>I', ResponseValue.UNLOCKED)), CmdResponse(True, pack('>I', 0x12345678)) ] sdp = SDP(VirtualDevice(respond_sequence=error_response.copy())) sdp._device.respond_sequence = error_response.copy() assert not sdp._send_data(CmdPacket(CommandTag.WRITE_DCD, 0, 0, 0), b'') assert sdp.status_code == StatusCode.WRITE_DCD_FAILURE sdp._device.respond_sequence = error_response.copy() assert not sdp._send_data(CmdPacket(CommandTag.WRITE_CSF, 0, 0, 0), b'') assert sdp.status_code == StatusCode.WRITE_CSF_FAILURE sdp._device.respond_sequence = error_response.copy() assert not sdp._send_data(CmdPacket(CommandTag.WRITE_FILE, 0, 0, 0), b'') assert sdp.status_code == StatusCode.WRITE_IMAGE_FAILURE sdp._device.respond_sequence = error_response.copy() assert not sdp._send_data(CmdPacket(CommandTag.WRITE_DCD, 0, 0, 0), b'') assert sdp.status_code == StatusCode.WRITE_DCD_FAILURE