# Path: demetsiiify/iiif.py
# METAMAP = {
#     'title': {'en': 'Title', 'de': 'Titel'},
#     'language': {'en': 'Language', 'de': 'Sprache'},
#     'genre': {'en': 'Genre', 'de': 'Genre'},
#     'creator': {'en': 'Creator', 'de': 'Urheber'},
#     'other_persons': {'en': 'Other Persons', 'de': 'Andere Personen'},
#     'publisher': {'en': 'Publisher', 'de': 'Veröffentlicht von'},
#     'pub_place': {'en': 'Publication Place', 'de': 'Publikationsort'},
#     'pub_date': {'en': 'Publication Date', 'de': 'Erscheinungsdatum'}
# }
# LICENSE_MAP = {
#     'pdm': 'http://creativecommons.org/licenses/publicdomain/',
#     'cc0': 'https://creativecommons.org/publicdomain/zero/1.0/',
#     'cc-by': 'http://creativecommons.org/licenses/by/4.0',
#     'cc-by-sa': 'http://creativecommons.org/licenses/by-sa/4.0',
#     'cc-by-nd': 'http://creativecommons.org/licenses/by-nd/4.0',
#     'cc-by-nc': 'http://creativecommons.org/licenses/by-nd/4.0',
#     'cc-by-nc-sa': 'http://creativecommons.org/licenses/by-nc-sa/4.0',
#     'cc-by-nc-nd': 'http://creativecommons.org/licenses/by-nc-nd/4.0'}
# def make_label(mets_meta: dict) -> str:
# def make_metadata(mets_meta: dict) -> List[dict]:
# def _get_canvases(toc_entry: TocEntry, manifest: Manifest) -> List[str]:
# def _add_toc_ranges(manifest: Manifest, toc_entries: Iterable[TocEntry]):
# def _make_empty_manifest(ident: str, label: str, base_url: str) -> Manifest:
# def _fill_manifest_metadata(manifest: Manifest, mets_metadata: dict) -> None:
# def make_image_info(itm: PhysicalItem, base_url: str) -> dict:
# def make_manifest(ident: str, mets_doc: MetsDocument,
#                   base_url: str) -> dict:
# def make_manifest_collection(
#         pagination: Pagination, label: str, collection_id: str,
#         per_page: int, base_url: str, page_num: Optional[int] = None,
#         coll_counts: Optional[Tuple[int, str, int]] = None) -> dict:
# def make_annotation_list(pagination: Pagination, request_url: str,
#                          request_args: dict, base_url: str) -> dict:
#     def _make_link(page_no: int) -> str:
# 
# Path: demetsiiify/mets.py
# NAMESPACES = {
#     'mets': 'http://www.loc.gov/METS/',
#     'mods': 'http://www.loc.gov/mods/v3',
#     'dv': 'http://dfg-viewer.de/',
#     'xlink': 'http://www.w3.org/1999/xlink'}
# class ImageInfo:
# class PhysicalItem:
# class TocEntry:
# class MetsParseError(Exception):
# class MetsDocument:
#     def max_dimensions(self):
#     def min_dimensions(self):
#     def __init__(self, message: str, debug_info: dict = None) -> None:
#     def __init__(self, mets_tree: etree.ElementTree, url: str = None,
#                  primary_id: str = None) -> None:
#     def _xpath(self, xpath: str,
#                elem: etree.Element = None) -> List[etree.Element]:
#     def _find(self, path: str, elem: etree.Element = None) -> etree.Element:
#     def _findall(self, path: str,
#                  elem: etree.Element = None) -> List[etree.Element]:
#     def _findtext(self, path: str, elem: etree.Element = None) -> str:
#     def _parse_title(self, title_elem: etree.Element) -> str:
#     def _parse_name(self, name_elem: etree.Element) -> str:
#     def _read_persons(self) -> Mapping[str, List[str]]:
#     def _read_origin(self) -> Mapping[str, str]:
#     def _get_unique_identifier(self) -> str:
#     def _read_titles(self) -> List[str]:
#     def _read_metadata(self) -> dict:
#     def _read_files(self) -> Dict[str, ImageInfo]:
#     def _read_physical_items(self) -> Dict[str, PhysicalItem]:
#     def _parse_tocentry(self, toc_elem: etree.Element,
#                         lmap: Mapping[str, List[str]]) -> TocEntry:
#     def _read_toc_entries(self) -> List[TocEntry]:
#     def _get_image_specs(self, file_elem: etree.Element) -> ImageInfo:
# def get_basic_info(mets_url):


import pytest
import shortuuid
    import json
from lxml import etree
from demetsiiify import iiif, mets



def _add_mock_sizes(mets_doc):
    for itm in mets_doc.physical_items.values():
        w, h = (256, 256)
        itm.image_ident = shortuuid.uuid()
        for f in itm.files:
            f.width = w
            f.height = h
            w = w * 2
            h = h * 2


def test_make_manifest(shared_datadir):
    mets_tree = etree.parse(
        str(shared_datadir / 'urn:nbn:de:gbv:23-drucke_li-1876-12.xml'))
    mets_doc = mets.MetsDocument(mets_tree)
    _add_mock_sizes(mets_doc)

# Path: demetsiiify/iiif.py
# METAMAP = {
#     'title': {'en': 'Title', 'de': 'Titel'},
#     'language': {'en': 'Language', 'de': 'Sprache'},
#     'genre': {'en': 'Genre', 'de': 'Genre'},
#     'creator': {'en': 'Creator', 'de': 'Urheber'},
#     'other_persons': {'en': 'Other Persons', 'de': 'Andere Personen'},
#     'publisher': {'en': 'Publisher', 'de': 'Veröffentlicht von'},
#     'pub_place': {'en': 'Publication Place', 'de': 'Publikationsort'},
#     'pub_date': {'en': 'Publication Date', 'de': 'Erscheinungsdatum'}
# }
# LICENSE_MAP = {
#     'pdm': 'http://creativecommons.org/licenses/publicdomain/',
#     'cc0': 'https://creativecommons.org/publicdomain/zero/1.0/',
#     'cc-by': 'http://creativecommons.org/licenses/by/4.0',
#     'cc-by-sa': 'http://creativecommons.org/licenses/by-sa/4.0',
#     'cc-by-nd': 'http://creativecommons.org/licenses/by-nd/4.0',
#     'cc-by-nc': 'http://creativecommons.org/licenses/by-nd/4.0',
#     'cc-by-nc-sa': 'http://creativecommons.org/licenses/by-nc-sa/4.0',
#     'cc-by-nc-nd': 'http://creativecommons.org/licenses/by-nc-nd/4.0'}
# def make_label(mets_meta: dict) -> str:
# def make_metadata(mets_meta: dict) -> List[dict]:
# def _get_canvases(toc_entry: TocEntry, manifest: Manifest) -> List[str]:
# def _add_toc_ranges(manifest: Manifest, toc_entries: Iterable[TocEntry]):
# def _make_empty_manifest(ident: str, label: str, base_url: str) -> Manifest:
# def _fill_manifest_metadata(manifest: Manifest, mets_metadata: dict) -> None:
# def make_image_info(itm: PhysicalItem, base_url: str) -> dict:
# def make_manifest(ident: str, mets_doc: MetsDocument,
#                   base_url: str) -> dict:
# def make_manifest_collection(
#         pagination: Pagination, label: str, collection_id: str,
#         per_page: int, base_url: str, page_num: Optional[int] = None,
#         coll_counts: Optional[Tuple[int, str, int]] = None) -> dict:
# def make_annotation_list(pagination: Pagination, request_url: str,
#                          request_args: dict, base_url: str) -> dict:
#     def _make_link(page_no: int) -> str:
# 
# Path: demetsiiify/mets.py
# NAMESPACES = {
#     'mets': 'http://www.loc.gov/METS/',
#     'mods': 'http://www.loc.gov/mods/v3',
#     'dv': 'http://dfg-viewer.de/',
#     'xlink': 'http://www.w3.org/1999/xlink'}
# class ImageInfo:
# class PhysicalItem:
# class TocEntry:
# class MetsParseError(Exception):
# class MetsDocument:
#     def max_dimensions(self):
#     def min_dimensions(self):
#     def __init__(self, message: str, debug_info: dict = None) -> None:
#     def __init__(self, mets_tree: etree.ElementTree, url: str = None,
#                  primary_id: str = None) -> None:
#     def _xpath(self, xpath: str,
#                elem: etree.Element = None) -> List[etree.Element]:
#     def _find(self, path: str, elem: etree.Element = None) -> etree.Element:
#     def _findall(self, path: str,
#                  elem: etree.Element = None) -> List[etree.Element]:
#     def _findtext(self, path: str, elem: etree.Element = None) -> str:
#     def _parse_title(self, title_elem: etree.Element) -> str:
#     def _parse_name(self, name_elem: etree.Element) -> str:
#     def _read_persons(self) -> Mapping[str, List[str]]:
#     def _read_origin(self) -> Mapping[str, str]:
#     def _get_unique_identifier(self) -> str:
#     def _read_titles(self) -> List[str]:
#     def _read_metadata(self) -> dict:
#     def _read_files(self) -> Dict[str, ImageInfo]:
#     def _read_physical_items(self) -> Dict[str, PhysicalItem]:
#     def _parse_tocentry(self, toc_elem: etree.Element,
#                         lmap: Mapping[str, List[str]]) -> TocEntry:
#     def _read_toc_entries(self) -> List[TocEntry]:
#     def _get_image_specs(self, file_elem: etree.Element) -> ImageInfo:
# def get_basic_info(mets_url):


# Path: tests/test_iiif.py
import pytest
import shortuuid
    import json
from lxml import etree
from demetsiiify import iiif, mets




def _add_mock_sizes(mets_doc):
    for itm in mets_doc.physical_items.values():
        w, h = (256, 256)
        itm.image_ident = shortuuid.uuid()
        for f in itm.files:
            f.width = w
            f.height = h
            w = w * 2
            h = h * 2


def test_make_manifest(shared_datadir):
    mets_tree = etree.parse(
        str(shared_datadir / 'urn:nbn:de:gbv:23-drucke_li-1876-12.xml'))
    mets_doc = mets.MetsDocument(mets_tree)
    _add_mock_sizes(mets_doc)

    manif = iiif.make_manifest(