# Path: dtformats/gzipfile.py
# class GZipFile(data_format.BinaryDataFile):
#   _FABRIC = data_format.BinaryDataFile.ReadDefinitionFile('gzipfile.yaml')
#   _GZIP_SIGNATURE = 0x8b1f
#   _COMPRESSION_METHOD_DEFLATE = 8
#   _FLAG_FTEXT = 0x01
#   _FLAG_FHCRC = 0x02
#   _FLAG_FEXTRA = 0x04
#   _FLAG_FNAME = 0x08
#   _FLAG_FCOMMENT = 0x10
#   _BUFFER_SIZE = 16 * 1024 * 1024
#   _DEBUG_INFO_MEMBER_FOOTER = [
#       ('checksum', 'Checksum', '_FormatIntegerAsHexadecimal8'),
#       ('uncompressed_data_size', 'Uncompressed data size',
#        '_FormatIntegerAsDecimal')]
#   _DEBUG_INFO_MEMBER_HEADER = [
#       ('signature', 'Signature', '_FormatIntegerAsHexadecimal4'),
#       ('compression_method', 'Compression method', '_FormatStreamAsDecimal'),
#       ('flags', 'Flags', '_FormatIntegerAsHexadecimal2'),
#       ('modification_time', 'Modification time', '_FormatIntegerAsPosixTime'),
#       ('operating_system', 'Operating system', '_FormatStreamAsDecimal'),
#       ('compression_flags', 'Compression flags',
#        '_FormatIntegerAsHexadecimal2')]
#   def _ReadCompressedData(self, zlib_decompressor, compressed_data):
#   def _ReadMemberCompressedData(self, file_object):
#   def _ReadMemberFooter(self, file_object):
#   def _ReadMemberHeader(self, file_object):
#   def ReadFileObject(self, file_object):
# 
# Path: tests/test_lib.py
# class BaseTestCase(unittest.TestCase):
# class TestOutputWriter(output_writers.OutputWriter):
#   _TEST_DATA_PATH = os.path.join(os.getcwd(), 'test_data')
#   def _GetTestFilePath(self, path_segments):
#   def _SkipIfPathNotExists(self, path):
#   def __init__(self):
#   def Close(self):
#   def Open(self):
#   def WriteText(self, text):


import unittest
from dtformats import gzipfile
from tests import test_lib
# when using pip.





class GZipFileTest(test_lib.BaseTestCase):
  """GZip file tests."""

  # pylint: disable=protected-access

  # TODO: test _ReadCompressedData function
  # TODO: test _ReadMemberCompressedData function
  # TODO: test _ReadMemberFooter function

  def testReadMemberHeader(self):
    """Tests the _ReadMemberHeader function."""
    output_writer = test_lib.TestOutputWriter()
    test_file = gzipfile.GZipFile(output_writer=output_writer)

    test_file_path = self._GetTestFilePath(['syslog.gz'])
    self._SkipIfPathNotExists(test_file_path)

    with open(test_file_path, 'rb') as file_object:
      test_file._ReadMemberHeader(file_object)

  def testReadFileObject(self):
    """Tests the ReadFileObject."""
    output_writer = test_lib.TestOutputWriter()
    # TODO: add debug=True

# Path: dtformats/gzipfile.py
# class GZipFile(data_format.BinaryDataFile):
#   _FABRIC = data_format.BinaryDataFile.ReadDefinitionFile('gzipfile.yaml')
#   _GZIP_SIGNATURE = 0x8b1f
#   _COMPRESSION_METHOD_DEFLATE = 8
#   _FLAG_FTEXT = 0x01
#   _FLAG_FHCRC = 0x02
#   _FLAG_FEXTRA = 0x04
#   _FLAG_FNAME = 0x08
#   _FLAG_FCOMMENT = 0x10
#   _BUFFER_SIZE = 16 * 1024 * 1024
#   _DEBUG_INFO_MEMBER_FOOTER = [
#       ('checksum', 'Checksum', '_FormatIntegerAsHexadecimal8'),
#       ('uncompressed_data_size', 'Uncompressed data size',
#        '_FormatIntegerAsDecimal')]
#   _DEBUG_INFO_MEMBER_HEADER = [
#       ('signature', 'Signature', '_FormatIntegerAsHexadecimal4'),
#       ('compression_method', 'Compression method', '_FormatStreamAsDecimal'),
#       ('flags', 'Flags', '_FormatIntegerAsHexadecimal2'),
#       ('modification_time', 'Modification time', '_FormatIntegerAsPosixTime'),
#       ('operating_system', 'Operating system', '_FormatStreamAsDecimal'),
#       ('compression_flags', 'Compression flags',
#        '_FormatIntegerAsHexadecimal2')]
#   def _ReadCompressedData(self, zlib_decompressor, compressed_data):
#   def _ReadMemberCompressedData(self, file_object):
#   def _ReadMemberFooter(self, file_object):
#   def _ReadMemberHeader(self, file_object):
#   def ReadFileObject(self, file_object):
# 
# Path: tests/test_lib.py
# class BaseTestCase(unittest.TestCase):
# class TestOutputWriter(output_writers.OutputWriter):
#   _TEST_DATA_PATH = os.path.join(os.getcwd(), 'test_data')
#   def _GetTestFilePath(self, path_segments):
#   def _SkipIfPathNotExists(self, path):
#   def __init__(self):
#   def Close(self):
#   def Open(self):
#   def WriteText(self, text):


# Path: tests/gzipfile.py
import unittest
from dtformats import gzipfile
from tests import test_lib

# when using pip.





class GZipFileTest(test_lib.BaseTestCase):
  """GZip file tests."""

  # pylint: disable=protected-access

  # TODO: test _ReadCompressedData function
  # TODO: test _ReadMemberCompressedData function
  # TODO: test _ReadMemberFooter function

  def testReadMemberHeader(self):
    """Tests the _ReadMemberHeader function."""
    output_writer = test_lib.TestOutputWriter()
    test_file = gzipfile.GZipFile(output_writer=output_writer)

    test_file_path = self._GetTestFilePath(['syslog.gz'])
    self._SkipIfPathNotExists(test_file_path)

    with open(test_file_path, 'rb') as file_object:
      test_file._ReadMemberHeader(file_object)

  def testReadFileObject(self):
    """Tests the ReadFileObject."""
    output_writer = test_lib.TestOutputWriter()
    # TODO: add debug=True

    test_file = gzipfile.GZipFile(output_writer=output_writer)