# Path: packtools/domain.py
# LOGGER = logging.getLogger(__name__)
# def _get_public_ids(sps_version):
# def _init_sps_version(xml_et, supported_versions=None):
# def StdSchematron(schema_name):
# def XSLT(xslt_name):
#     def __init__(self, pipeline=catalogs.StyleCheckingPipeline, label=u''):
#     def validate(self, xmlfile):
#     def __init__(self, dtd, label=u''):
#     def validate(self, xmlfile):
#     def __init__(self, sch, label=u''):
#     def from_catalog(cls, ref, **kwargs):
#     def validate(self, xmlfile):
# def iter_schematronvalidators(iterable):
#     def __init__(self, file, dtd=None, style_validators=None):
#     def parse(cls, file, no_doctype=False, sps_version=None,
#             supported_sps_versions=None, extra_sch_schemas=None, **kwargs):
#     def sps_version(self):
#     def dtd_validator(self):
#     def validate(self):
#     def validate_style(self):
#     def validate_all(self, fail_fast=False):
#     def _annotate_error(self, element, error):
#     def annotate_errors(self, fail_fast=False):
#     def __repr__(self):
#     def meta(self):
#     def assets(self):
#     def lookup_assets(self, base):
#     def __init__(self, file, xslt=None, css=None, print_css=None, js=None,
#                  permlink=None, url_article_page=None, url_download_ris=None,
#                  gs_abstract=None, output_style=None):
#     def parse(cls, file, valid_only=True, **kwargs):
#     def languages(self):
#     def language(self):
#     def abstract_languages(self):
#     def _is_aop(self):
#     def _get_issue_label(self):
#     def _get_bibliographic_legend(self):
#     def __iter__(self):
#     def generate(self, lang):
# class PyValidator(object):
# class DTDValidator(object):
# class SchematronValidator(object):
# class XMLValidator(object):
# class HTMLGenerator(object):


import unittest
import io
import os
from tempfile import NamedTemporaryFile
from lxml import etree
from packtools import domain
def setup_tmpfile(method):
    def wrapper(self):
        valid_tmpfile = NamedTemporaryFile()
        valid_tmpfile.write(b'<a><b>bar</b></a>')
        valid_tmpfile.seek(0)
        self.valid_tmpfile = valid_tmpfile

        method(self)

        self.valid_tmpfile.close()

    return wrapper

SAMPLES_PATH = os.path.join(
    os.path.dirname(os.path.abspath(__file__)),
    'samples')


def get_xml_tree_from_string(text='<a><b>bar</b></a>'):
    return etree.parse(io.BytesIO(text.encode('utf-8')))


def get_xml_tree_from_file(filename):
    return etree.parse(os.path.join(SAMPLES_PATH, filename))


class HTMLGeneratorTests(unittest.TestCase):

    @setup_tmpfile
    def test_initializes_with_filepath(self):

# Path: packtools/domain.py
# LOGGER = logging.getLogger(__name__)
# def _get_public_ids(sps_version):
# def _init_sps_version(xml_et, supported_versions=None):
# def StdSchematron(schema_name):
# def XSLT(xslt_name):
#     def __init__(self, pipeline=catalogs.StyleCheckingPipeline, label=u''):
#     def validate(self, xmlfile):
#     def __init__(self, dtd, label=u''):
#     def validate(self, xmlfile):
#     def __init__(self, sch, label=u''):
#     def from_catalog(cls, ref, **kwargs):
#     def validate(self, xmlfile):
# def iter_schematronvalidators(iterable):
#     def __init__(self, file, dtd=None, style_validators=None):
#     def parse(cls, file, no_doctype=False, sps_version=None,
#             supported_sps_versions=None, extra_sch_schemas=None, **kwargs):
#     def sps_version(self):
#     def dtd_validator(self):
#     def validate(self):
#     def validate_style(self):
#     def validate_all(self, fail_fast=False):
#     def _annotate_error(self, element, error):
#     def annotate_errors(self, fail_fast=False):
#     def __repr__(self):
#     def meta(self):
#     def assets(self):
#     def lookup_assets(self, base):
#     def __init__(self, file, xslt=None, css=None, print_css=None, js=None,
#                  permlink=None, url_article_page=None, url_download_ris=None,
#                  gs_abstract=None, output_style=None):
#     def parse(cls, file, valid_only=True, **kwargs):
#     def languages(self):
#     def language(self):
#     def abstract_languages(self):
#     def _is_aop(self):
#     def _get_issue_label(self):
#     def _get_bibliographic_legend(self):
#     def __iter__(self):
#     def generate(self, lang):
# class PyValidator(object):
# class DTDValidator(object):
# class SchematronValidator(object):
# class XMLValidator(object):
# class HTMLGenerator(object):


# Path: tests/test_htmlgenerator.py
import unittest
import io
import os
from tempfile import NamedTemporaryFile
from lxml import etree
from packtools import domain

def setup_tmpfile(method):
    def wrapper(self):
        valid_tmpfile = NamedTemporaryFile()
        valid_tmpfile.write(b'<a><b>bar</b></a>')
        valid_tmpfile.seek(0)
        self.valid_tmpfile = valid_tmpfile

        method(self)

        self.valid_tmpfile.close()

    return wrapper

SAMPLES_PATH = os.path.join(
    os.path.dirname(os.path.abspath(__file__)),
    'samples')


def get_xml_tree_from_string(text='<a><b>bar</b></a>'):
    return etree.parse(io.BytesIO(text.encode('utf-8')))


def get_xml_tree_from_file(filename):
    return etree.parse(os.path.join(SAMPLES_PATH, filename))


class HTMLGeneratorTests(unittest.TestCase):

    @setup_tmpfile
    def test_initializes_with_filepath(self):

        self.assertTrue(domain.HTMLGenerator.parse(self.valid_tmpfile.name, valid_only=False))