# Path: diffoscope/comparators/zip.py
# class ZipFile(File):
#     CONTAINER_CLASS = ZipContainer
#     RE_FILE_TYPE = re.compile(r'^(Zip archive|Java archive|EPUB document|OpenDocument (Text|Spreadsheet|Presentation|Drawing|Formula|Template|Text Template))\b')
# 
#     def compare_details(self, other, source=None):
#         zipinfo_difference = Difference.from_command(Zipinfo, self.path, other.path) or \
#                              Difference.from_command(ZipinfoVerbose, self.path, other.path)
#         return [zipinfo_difference]
# 
# class MozillaZipFile(File):
#     CONTAINER_CLASS = MozillaZipContainer
# 
#     @staticmethod
#     def recognizes(file):
#         # Mozilla-optimized ZIPs start with a 32-bit little endian integer
#         # indicating the amount of data to preload, followed by the ZIP
#         # central directory (with a PK\x01\x02 signature)
#         with open(file.path, 'rb') as f:
#             preload = f.read(4)
#             if len(preload) == 4:
#                 signature = f.read(4)
#                 return signature == b'PK\x01\x02'
# 
#     def compare_details(self, other, source=None):
#         zipinfo_difference = Difference.from_command(MozillaZipinfo, self.path, other.path) or \
#                              Difference.from_command(MozillaZipinfoVerbose, self.path, other.path)
#         return [zipinfo_difference]


import pytest
from diffoscope.comparators.zip import ZipFile, MozillaZipFile
from utils.data import load_fixture, get_data
from utils.tools import skip_unless_tools_exist
from utils.nonexisting import assert_non_existing
# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2015 Jérémy Bobbio <lunar@debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# diffoscope is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.





zip1 = load_fixture('test1.zip')
zip2 = load_fixture('test2.zip')
mozzip1 = load_fixture('test1.mozzip')
mozzip2 = load_fixture('test2.mozzip')


def test_identification(zip1):

# Path: diffoscope/comparators/zip.py
# class ZipFile(File):
#     CONTAINER_CLASS = ZipContainer
#     RE_FILE_TYPE = re.compile(r'^(Zip archive|Java archive|EPUB document|OpenDocument (Text|Spreadsheet|Presentation|Drawing|Formula|Template|Text Template))\b')
# 
#     def compare_details(self, other, source=None):
#         zipinfo_difference = Difference.from_command(Zipinfo, self.path, other.path) or \
#                              Difference.from_command(ZipinfoVerbose, self.path, other.path)
#         return [zipinfo_difference]
# 
# class MozillaZipFile(File):
#     CONTAINER_CLASS = MozillaZipContainer
# 
#     @staticmethod
#     def recognizes(file):
#         # Mozilla-optimized ZIPs start with a 32-bit little endian integer
#         # indicating the amount of data to preload, followed by the ZIP
#         # central directory (with a PK\x01\x02 signature)
#         with open(file.path, 'rb') as f:
#             preload = f.read(4)
#             if len(preload) == 4:
#                 signature = f.read(4)
#                 return signature == b'PK\x01\x02'
# 
#     def compare_details(self, other, source=None):
#         zipinfo_difference = Difference.from_command(MozillaZipinfo, self.path, other.path) or \
#                              Difference.from_command(MozillaZipinfoVerbose, self.path, other.path)
#         return [zipinfo_difference]


# Path: tests/comparators/test_zip.py
import pytest
from diffoscope.comparators.zip import ZipFile, MozillaZipFile
from utils.data import load_fixture, get_data
from utils.tools import skip_unless_tools_exist
from utils.nonexisting import assert_non_existing

# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2015 Jérémy Bobbio <lunar@debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# diffoscope is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.





zip1 = load_fixture('test1.zip')
zip2 = load_fixture('test2.zip')
mozzip1 = load_fixture('test1.mozzip')
mozzip2 = load_fixture('test2.mozzip')


def test_identification(zip1):

    assert isinstance(zip1, ZipFile)