# Path: dtformats/cups_ipp.py
# class CupsIppFile(data_format.BinaryDataFile):
#   _FABRIC = data_format.BinaryDataFile.ReadDefinitionFile('cups_ipp.yaml')
#   _DELIMITER_TAG_OPERATION_ATTRIBUTES = 0x01
#   _DELIMITER_TAG_JOB_ATTRIBUTES = 0x02
#   _DELIMITER_TAG_END_OF_ATTRIBUTES = 0x03
#   _DELIMITER_TAG_PRINTER_ATTRIBUTES = 0x04
#   _DELIMITER_TAG_UNSUPPORTED_ATTRIBUTES = 0x05
#   _DELIMITER_TAGS = frozenset([
#       _DELIMITER_TAG_OPERATION_ATTRIBUTES,
#       _DELIMITER_TAG_JOB_ATTRIBUTES,
#       _DELIMITER_TAG_PRINTER_ATTRIBUTES,
#       _DELIMITER_TAG_UNSUPPORTED_ATTRIBUTES])
#   _TAG_VALUE_INTEGER = 0x21
#   _TAG_VALUE_BOOLEAN = 0x22
#   _TAG_VALUE_ENUM = 0x23
#   _TAG_VALUE_DATE_TIME = 0x31
#   _TAG_VALUE_RESOLUTION = 0x32
#   _TAG_VALUE_TEXT_WITHOUT_LANGUAGE = 0x41
#   _TAG_VALUE_NAME_WITHOUT_LANGUAGE = 0x42
#   _TAG_VALUE_KEYWORD = 0x44
#   _TAG_VALUE_URI = 0x45
#   _TAG_VALUE_URI_SCHEME = 0x46
#   _TAG_VALUE_CHARSET = 0x47
#   _TAG_VALUE_NATURAL_LANGUAGE = 0x48
#   _TAG_VALUE_MEDIA_TYPE = 0x49
#   _ASCII_STRING_VALUES = frozenset([
#       _TAG_VALUE_KEYWORD,
#       _TAG_VALUE_URI,
#       _TAG_VALUE_URI_SCHEME,
#       _TAG_VALUE_CHARSET,
#       _TAG_VALUE_NATURAL_LANGUAGE,
#       _TAG_VALUE_MEDIA_TYPE])
#   _INTEGER_TAG_VALUES = frozenset([
#       _TAG_VALUE_INTEGER, _TAG_VALUE_ENUM])
#   _STRING_WITHOUT_LANGUAGE_VALUES = frozenset([
#       _TAG_VALUE_TEXT_WITHOUT_LANGUAGE,
#       _TAG_VALUE_NAME_WITHOUT_LANGUAGE])
#   _TAG_VALUE_STRINGS = {
#       0x01: 'operation-attributes-tag',
#       0x02: 'job-attributes-tag',
#       0x03: 'end-of-attributes-tag',
#       0x04: 'printer-attributes-tag',
#       0x05: 'unsupported-attributes-tag',
# 
#       0x0f: 'chunking-end-of-attributes-tag',
# 
#       0x13: 'no-value',
# 
#       0x21: 'integer',
#       0x22: 'boolean',
#       0x23: 'enum',
# 
#       0x30: 'octetString',
#       0x31: 'dateTime',
#       0x32: 'resolution',
#       0x33: 'rangeOfInteger',
# 
#       0x35: 'textWithLanguage',
#       0x36: 'nameWithLanguage',
# 
#       0x41: 'textWithoutLanguage',
#       0x42: 'nameWithoutLanguage',
# 
#       0x44: 'keyword',
#       0x45: 'uri',
#       0x46: 'uriScheme',
#       0x47: 'charset',
#       0x48: 'naturalLanguage',
#       0x49: 'mimeMediaType',
#   }
#   _DEBUG_INFO_ATTRIBUTE = [
#       ('tag_value', 'Tag value', '_FormatIntegerAsTagValue'),
#       ('name_size', 'Name size', '_FormatIntegerAsDecimal'),
#       ('name', 'Name', None),
#       ('value_data_size', 'Value data size', '_FormatIntegerAsDecimal'),
#       ('value_data', 'Value data', '_FormatDataInHexadecimal')]
#   _DEBUG_INFO_HEADER = [
#       ('major_version', 'Major version', '_FormatIntegerAsDecimal'),
#       ('minor_version', 'Minor version', '_FormatIntegerAsDecimal'),
#       ('operation_identifier', 'Operation identifier',
#        '_FormatIntegerAsHexadecimal4'),
#       ('request_identifier', 'Request identifier',
#        '_FormatIntegerAsHexadecimal8')]
#   def __init__(self, debug=False, output_writer=None):
#   def _FormatIntegerAsTagValue(self, integer):
#   def _ReadAttribute(self, file_object):
#   def _ReadAttributesGroup(self, file_object):
#   def _ReadBooleanValue(self, byte_stream):
#   def _ReadDateTimeValue(self, byte_stream, file_offset):
#   def _ReadIntegerValue(self, byte_stream, file_offset):
#   def _ReadHeader(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 cups_ipp
from tests import test_lib



class CupsIppFileTest(test_lib.BaseTestCase):
  """CUPS Internet Printing Protocol (IPP) file tests."""

  # pylint: disable=protected-access

  # TODO: test _FormatIntegerAsTagValue function

  # TODO: test _ReadAttribute function
  # TODO: test _ReadAttributesGroup function
  # TODO: test _ReadBooleanValue function
  # TODO: test _ReadDateTimeValue function
  # TODO: test _ReadIntegerValue function

  def testReadHeader(self):
    """Tests the _ReadHeader function."""
    output_writer = test_lib.TestOutputWriter()
    test_file = cups_ipp.CupsIppFile(output_writer=output_writer)

    test_file_path = self._GetTestFilePath(['cups_ipp_2.0'])
    self._SkipIfPathNotExists(test_file_path)

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

  def testReadFileObject(self):
    """Tests the ReadFileObject function."""
    output_writer = test_lib.TestOutputWriter()

# Path: dtformats/cups_ipp.py
# class CupsIppFile(data_format.BinaryDataFile):
#   _FABRIC = data_format.BinaryDataFile.ReadDefinitionFile('cups_ipp.yaml')
#   _DELIMITER_TAG_OPERATION_ATTRIBUTES = 0x01
#   _DELIMITER_TAG_JOB_ATTRIBUTES = 0x02
#   _DELIMITER_TAG_END_OF_ATTRIBUTES = 0x03
#   _DELIMITER_TAG_PRINTER_ATTRIBUTES = 0x04
#   _DELIMITER_TAG_UNSUPPORTED_ATTRIBUTES = 0x05
#   _DELIMITER_TAGS = frozenset([
#       _DELIMITER_TAG_OPERATION_ATTRIBUTES,
#       _DELIMITER_TAG_JOB_ATTRIBUTES,
#       _DELIMITER_TAG_PRINTER_ATTRIBUTES,
#       _DELIMITER_TAG_UNSUPPORTED_ATTRIBUTES])
#   _TAG_VALUE_INTEGER = 0x21
#   _TAG_VALUE_BOOLEAN = 0x22
#   _TAG_VALUE_ENUM = 0x23
#   _TAG_VALUE_DATE_TIME = 0x31
#   _TAG_VALUE_RESOLUTION = 0x32
#   _TAG_VALUE_TEXT_WITHOUT_LANGUAGE = 0x41
#   _TAG_VALUE_NAME_WITHOUT_LANGUAGE = 0x42
#   _TAG_VALUE_KEYWORD = 0x44
#   _TAG_VALUE_URI = 0x45
#   _TAG_VALUE_URI_SCHEME = 0x46
#   _TAG_VALUE_CHARSET = 0x47
#   _TAG_VALUE_NATURAL_LANGUAGE = 0x48
#   _TAG_VALUE_MEDIA_TYPE = 0x49
#   _ASCII_STRING_VALUES = frozenset([
#       _TAG_VALUE_KEYWORD,
#       _TAG_VALUE_URI,
#       _TAG_VALUE_URI_SCHEME,
#       _TAG_VALUE_CHARSET,
#       _TAG_VALUE_NATURAL_LANGUAGE,
#       _TAG_VALUE_MEDIA_TYPE])
#   _INTEGER_TAG_VALUES = frozenset([
#       _TAG_VALUE_INTEGER, _TAG_VALUE_ENUM])
#   _STRING_WITHOUT_LANGUAGE_VALUES = frozenset([
#       _TAG_VALUE_TEXT_WITHOUT_LANGUAGE,
#       _TAG_VALUE_NAME_WITHOUT_LANGUAGE])
#   _TAG_VALUE_STRINGS = {
#       0x01: 'operation-attributes-tag',
#       0x02: 'job-attributes-tag',
#       0x03: 'end-of-attributes-tag',
#       0x04: 'printer-attributes-tag',
#       0x05: 'unsupported-attributes-tag',
# 
#       0x0f: 'chunking-end-of-attributes-tag',
# 
#       0x13: 'no-value',
# 
#       0x21: 'integer',
#       0x22: 'boolean',
#       0x23: 'enum',
# 
#       0x30: 'octetString',
#       0x31: 'dateTime',
#       0x32: 'resolution',
#       0x33: 'rangeOfInteger',
# 
#       0x35: 'textWithLanguage',
#       0x36: 'nameWithLanguage',
# 
#       0x41: 'textWithoutLanguage',
#       0x42: 'nameWithoutLanguage',
# 
#       0x44: 'keyword',
#       0x45: 'uri',
#       0x46: 'uriScheme',
#       0x47: 'charset',
#       0x48: 'naturalLanguage',
#       0x49: 'mimeMediaType',
#   }
#   _DEBUG_INFO_ATTRIBUTE = [
#       ('tag_value', 'Tag value', '_FormatIntegerAsTagValue'),
#       ('name_size', 'Name size', '_FormatIntegerAsDecimal'),
#       ('name', 'Name', None),
#       ('value_data_size', 'Value data size', '_FormatIntegerAsDecimal'),
#       ('value_data', 'Value data', '_FormatDataInHexadecimal')]
#   _DEBUG_INFO_HEADER = [
#       ('major_version', 'Major version', '_FormatIntegerAsDecimal'),
#       ('minor_version', 'Minor version', '_FormatIntegerAsDecimal'),
#       ('operation_identifier', 'Operation identifier',
#        '_FormatIntegerAsHexadecimal4'),
#       ('request_identifier', 'Request identifier',
#        '_FormatIntegerAsHexadecimal8')]
#   def __init__(self, debug=False, output_writer=None):
#   def _FormatIntegerAsTagValue(self, integer):
#   def _ReadAttribute(self, file_object):
#   def _ReadAttributesGroup(self, file_object):
#   def _ReadBooleanValue(self, byte_stream):
#   def _ReadDateTimeValue(self, byte_stream, file_offset):
#   def _ReadIntegerValue(self, byte_stream, file_offset):
#   def _ReadHeader(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/cups_ipp.py
import unittest
from dtformats import cups_ipp
from tests import test_lib




class CupsIppFileTest(test_lib.BaseTestCase):
  """CUPS Internet Printing Protocol (IPP) file tests."""

  # pylint: disable=protected-access

  # TODO: test _FormatIntegerAsTagValue function

  # TODO: test _ReadAttribute function
  # TODO: test _ReadAttributesGroup function
  # TODO: test _ReadBooleanValue function
  # TODO: test _ReadDateTimeValue function
  # TODO: test _ReadIntegerValue function

  def testReadHeader(self):
    """Tests the _ReadHeader function."""
    output_writer = test_lib.TestOutputWriter()
    test_file = cups_ipp.CupsIppFile(output_writer=output_writer)

    test_file_path = self._GetTestFilePath(['cups_ipp_2.0'])
    self._SkipIfPathNotExists(test_file_path)

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

  def testReadFileObject(self):
    """Tests the ReadFileObject function."""
    output_writer = test_lib.TestOutputWriter()

    test_file = cups_ipp.CupsIppFile(