class_docstr: Mock SEVIRI L2 BUFR data.
docstr: Initialize by mocking test data for testing the SEVIRI L2 BUFR reader.
docstr_tok: ["Initialize","by","mocking","test","data","for","testing","the","SEVIRI","L2","BUFR","reader","."]
code: def __init__(self, filename, with_adef=False, rect_lon="default"):
      """Initialize by mocking test data for testing the SEVIRI L2 BUFR reader."""
      import eccodes as ec
  
      from satpy.readers.seviri_l2_bufr import SeviriL2BufrFileHandler
  
      self.buf1 = ec.codes_bufr_new_from_samples(
          "BUFR4_local_satellite"
      )
      ec.codes_set(self.buf1, "unpack", 1)
      # write the bufr test data twice as we want to read in and then concatenate the data in the reader
      # 55 id corresponds to METEOSAT 8`
      ec.codes_set(self.buf1, "satelliteIdentifier", 56)
      ec.codes_set_array(self.buf1, "#1#latitude", LAT)
      ec.codes_set_array(self.buf1, "#1#latitude", LAT)
      ec.codes_set_array(self.buf1, "#1#longitude", LON)
      ec.codes_set_array(self.buf1, "#1#longitude", LON)
      ec.codes_set_array(self.buf1, "#1#brightnessTemperature", DATA)
      ec.codes_set_array(self.buf1, "#1#brightnessTemperature", DATA)
  
      self.m = mock.mock_open()
      # only our offline product contain MPEF product headers so we get the metadata from there
      if "BUFRProd" in filename:
          with mock.patch(
              "satpy.readers.seviri_l2_bufr.np.fromfile"
          ) as fromfile:
              fromfile.return_value = MPEF_PRODUCT_HEADER
              with mock.patch(
                  "satpy.readers.seviri_l2_bufr.recarray2dict"
              ) as recarray2dict:
                  recarray2dict.side_effect = lambda x: x
                  self.fh = SeviriL2BufrFileHandler(
                      filename,
                      FILENAME_INFO2,
                      FILETYPE_INFO,
                      with_area_definition=with_adef,
                      rectification_longitude=rect_lon,
                  )
                  self.fh.mpef_header = MPEF_PRODUCT_HEADER
  
      else:
          # No Mpef Header  so we get the metadata from the BUFR messages
          with mock.patch(
              "satpy.readers.seviri_l2_bufr.open", self.m, create=True
          ):
              with mock.patch(
                  "eccodes.codes_bufr_new_from_file",
                  side_effect=[
                      self.buf1,
                      None,
                      self.buf1,
                      None,
                      self.buf1,
                      None,
                  ],
              ) as ec1:
                  ec1.return_value = ec1.side_effect
                  with mock.patch("eccodes.codes_set") as ec2:
                      ec2.return_value = 1
                      with mock.patch("eccodes.codes_release") as ec5:
                          ec5.return_value = 1
                          self.fh = SeviriL2BufrFileHandler(
                              filename,
                              FILENAME_INFO,
                              FILETYPE_INFO,
                              with_area_definition=with_adef,
                              rectification_longitude=rect_lon,
                          )
  
imports: import sys
  import unittest
  from datetime import datetime
  from unittest import mock
  import dask.array
  import numpy
  import pytest
  from pyresample import geometry
  from satpy.tests.utils import make_dataid
label_desc: Use image node_id 1 to create a new SeviriL2BufrData object  with example: obj = SeviriL2BufrData(filename, with_adef, rect_lon)