# Path: diffoscope/config.py
# class Config(object):
#     max_diff_block_lines = 256
#     max_diff_block_lines_parent = 50
#     max_diff_block_lines_saved = float("inf")
#     # html-dir output uses ratio * max-diff-block-lines as its limit
#     max_diff_block_lines_html_dir_ratio = 4
#     # GNU diff cannot process arbitrary large files :(
#     max_diff_input_lines = 2 ** 20
#     max_report_size = 2000 * 2 ** 10 # 2000 kB
#     max_text_report_size = 0
#     max_report_child_size = 500 * 2 ** 10
#     new_file = False
#     fuzzy_threshold = 60
#     enforce_constraints = True
#     excludes = ()
# 
#     _singleton = {}
# 
#     def __init__(self):
#         self.__dict__ = self._singleton
# 
#     def __setattr__(self, k, v):
#         super(Config, self).__setattr__(k, v)
# 
#         if self.enforce_constraints:
#             self.check_constraints()
# 
#     def check_constraints(self):
#         if self.max_diff_block_lines < self.max_diff_block_lines_parent:  # noqa
#             raise ValueError("max_diff_block_lines ({0.max_diff_block_lines}) "
#                 "cannot be smaller than max_diff_block_lines_parent "
#                 "({0.max_diff_block_lines_parent})".format(self),
#             )
# 
#         max_ = self.max_diff_block_lines_html_dir_ratio * \
#             self.max_diff_block_lines
#         if self.max_diff_block_lines_saved < max_:  # noqa
#             raise ValueError("max_diff_block_lines_saved "
#                 "({0.max_diff_block_lines_saved}) cannot be smaller than "
#                 "{0.max_diff_block_lines_html_dir_ratio} * "
#                 "max_diff_block_lines ({1})".format(self, max_),
#             )
# 
# 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]


import pytest
from diffoscope.config import Config
from diffoscope.comparators.zip import ZipFile
from diffoscope.comparators.missing_file import MissingFile
from utils.data import load_fixture, get_data
from utils.tools import skip_unless_tools_exist
# 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/>.





epub1 = load_fixture('test1.epub')
epub2 = load_fixture('test2.epub')

def test_identification(epub1):
    assert isinstance(epub1, ZipFile)

def test_no_differences(epub1):
    difference = epub1.compare(epub1)
    assert difference is None

@pytest.fixture
def differences(epub1, epub2):
    return epub1.compare(epub2).details

@skip_unless_tools_exist('zipinfo')
def test_differences(differences):
    assert differences[0].source1 == 'zipinfo {}'
    assert differences[0].source2 == 'zipinfo {}'
    assert differences[1].source1 == 'content.opf'

# Path: diffoscope/config.py
# class Config(object):
#     max_diff_block_lines = 256
#     max_diff_block_lines_parent = 50
#     max_diff_block_lines_saved = float("inf")
#     # html-dir output uses ratio * max-diff-block-lines as its limit
#     max_diff_block_lines_html_dir_ratio = 4
#     # GNU diff cannot process arbitrary large files :(
#     max_diff_input_lines = 2 ** 20
#     max_report_size = 2000 * 2 ** 10 # 2000 kB
#     max_text_report_size = 0
#     max_report_child_size = 500 * 2 ** 10
#     new_file = False
#     fuzzy_threshold = 60
#     enforce_constraints = True
#     excludes = ()
# 
#     _singleton = {}
# 
#     def __init__(self):
#         self.__dict__ = self._singleton
# 
#     def __setattr__(self, k, v):
#         super(Config, self).__setattr__(k, v)
# 
#         if self.enforce_constraints:
#             self.check_constraints()
# 
#     def check_constraints(self):
#         if self.max_diff_block_lines < self.max_diff_block_lines_parent:  # noqa
#             raise ValueError("max_diff_block_lines ({0.max_diff_block_lines}) "
#                 "cannot be smaller than max_diff_block_lines_parent "
#                 "({0.max_diff_block_lines_parent})".format(self),
#             )
# 
#         max_ = self.max_diff_block_lines_html_dir_ratio * \
#             self.max_diff_block_lines
#         if self.max_diff_block_lines_saved < max_:  # noqa
#             raise ValueError("max_diff_block_lines_saved "
#                 "({0.max_diff_block_lines_saved}) cannot be smaller than "
#                 "{0.max_diff_block_lines_html_dir_ratio} * "
#                 "max_diff_block_lines ({1})".format(self, max_),
#             )
# 
# 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]


# Path: tests/comparators/test_epub.py
import pytest
from diffoscope.config import Config
from diffoscope.comparators.zip import ZipFile
from diffoscope.comparators.missing_file import MissingFile
from utils.data import load_fixture, get_data
from utils.tools import skip_unless_tools_exist

# 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/>.





epub1 = load_fixture('test1.epub')
epub2 = load_fixture('test2.epub')

def test_identification(epub1):
    assert isinstance(epub1, ZipFile)

def test_no_differences(epub1):
    difference = epub1.compare(epub1)
    assert difference is None

@pytest.fixture
def differences(epub1, epub2):
    return epub1.compare(epub2).details

@skip_unless_tools_exist('zipinfo')
def test_differences(differences):
    assert differences[0].source1 == 'zipinfo {}'
    assert differences[0].source2 == 'zipinfo {}'
    assert differences[1].source1 == 'content.opf'

    assert differences[1].source2 == 'content.opf'