'Testing the handle_packet_as_receiver method'

def test_handle_packet_as_receiver(self):

    def mocked_handle_error(_dummy1, _dummy2, error_msg=None):
        mocked_handle_error.called = True
    mocked_handle_error.called = False
    self.handler._handle_error = mocked_handle_error
    mock_session = MockObject()
    mock_session.last_received_packet = None
    mock_session.block_size = 42
    mock_session.timeout = 44
    packet = {'opcode': OPCODE_OACK, 'options': {'blksize': 43, 'timeout': 45}}
    self.handler._handle_packet_as_receiver(mock_session, packet)
    self.assertTrue(mocked_handle_error.called)
    mocked_handle_error.called = False
    packet['options']['blksize'] = 42
    self.handler._handle_packet_as_receiver(mock_session, packet)
    self.assertTrue(mocked_handle_error.called)
    mock_session.last_received_packet = True
    mocked_handle_error.called = False
    self.handler._handle_packet_as_receiver(mock_session, packet)
    self.assertTrue(mocked_handle_error.called)
    packet['options']['timeout'] = 44
    packet['opcode'] = OPCODE_ERROR
    mocked_handle_error.called = False
    self.handler._handle_packet_as_receiver(mock_session, packet)
    self.assertTrue(mocked_handle_error.called)
