# Path: tabun_api/utils.py
# def parse_html(data, encoding='utf-8'):
# def parse_html_fragment(data, encoding='utf-8'):
#     def __init__(self, params=None):
#     def format(self, node, with_cutted=True):
#     def format_part(self, node, with_cutted=True):
#     def element_children(self, item, noblock=False):
#     def process_br(self, item, data, depth, with_cutted):
#     def default_process(self, item, data, depth, with_cutted):
#     def format_item_tail(self, item, data, depth, full_queue):
#     def format_text(self, ntext, data=None):
#     def escape(self, ntext):
#     def process_a(self, item, data, depth, with_cutted):
#     def process_span(self, item, data, depth, with_cutted):
#     def process_li(self, item, data, depth, with_cutted):
#     def process_blockquote(self, item, data, depth, with_cutted):
#     def process_hr(self, item, data, depth, with_cutted):
#     def process_s(self, item, data, depth, with_cutted):
# def htmlToString(node, with_cutted=True, fancy=True, vk_links=False, hr_lines=True, disable_links=False):
# def node2string(node, encoding="utf-8"):
# def mon2num(s):
# def is_cut(item):
# def find_images(body, spoiler_title=True, no_other=False):
# def encode_multipart_formdata(fields, files, boundary=None):
# def get_content_type(filename):
# def send_form(url, fields, files, timeout=None, headers=None):
# def find_substring(s, start, end, extend=False, with_start=True, with_end=True):
# def download(url, maxmem=20 * 1024 * 1024, timeout=5, waitout=15, headers=None):
# def find_good_image(urls, maxmem=20 * 1024 * 1024):
# def generate_comments_tree(comms):
# def parse_avatar_url(url):
# def decode_cf_email(data):
# def decode_cf_email_for_link(m):
# def replace_cloudflare_emails(data):
# def normalize_body(body=None, raw_body=None, cls='text'):
# def html_escape(s, single_quote=False):
# def escape_topic_contents(data, may_be_short=False):
# def escape_comment_contents(data):
# def escape_blog_content(data):
# def escape_profile_content(data):
# def parse_datetime(s, utc=True):
# def gen_user_agent():
# def get_cookies_dict(headers):
# def is_module_available(name):
# def build_proxy_params(proxy=None):
# class HTMLFormatter(object):
#     NEWLINE = -1
#     L = []


import pytest
from tabun_api import utils

    '<a href="mailto:почта@ya.ru">почта@ya.ru</a>',
), (
    'link_href_attrs',
    '<a title="1" href="/cdn-cgi/l/email-protection#1bcba4cba5ca9cca99cbab5b7e6d7e69626b74756235696e" target="_blank">foo</a><br/>',
    '<a title="1" href="mailto:почта@everypony.ru" target="_blank">foo</a><br/>',
), (
    'link_href_attrs_text',
    '<a title="1" href="/cdn-cgi/l/email-protection#d1016e016f00560053016191b4a7b4a3a8a1bebfa8ffa3a4" target="_blank"><span class="__cf_email__" data-cfemail="d0a0bfb3b8a4b190b5a6b5a2a9a0bfbea9fea2a5">[email&#160;protected]</span></a>',
    '<a title="1" href="mailto:почта@everypony.ru" target="_blank">pochta@everypony.ru</a>',
), (
    'text',
    '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="572738343f233617322132252e2738392e792522">[email&#160;protected]</a>',
    'pochta@everypony.ru',
)]


@pytest.mark.parametrize(
    'input_html,output_html',
    [pytest.param(*x[1:], id=x[0]) for i, x in enumerate(test_cases)]
)
def test_replace_cloudflare_emails_unicode(input_html, output_html):
    assert utils.replace_cloudflare_emails(input_html.encode('utf-8')) == output_html.encode('utf-8')


@pytest.mark.parametrize(
    'input_html,output_html',
    [pytest.param(*x[1:], id=x[0]) for i, x in enumerate(test_cases)]
)
def test_replace_cloudflare_emails_bytes(input_html, output_html):

# Path: tabun_api/utils.py
# def parse_html(data, encoding='utf-8'):
# def parse_html_fragment(data, encoding='utf-8'):
#     def __init__(self, params=None):
#     def format(self, node, with_cutted=True):
#     def format_part(self, node, with_cutted=True):
#     def element_children(self, item, noblock=False):
#     def process_br(self, item, data, depth, with_cutted):
#     def default_process(self, item, data, depth, with_cutted):
#     def format_item_tail(self, item, data, depth, full_queue):
#     def format_text(self, ntext, data=None):
#     def escape(self, ntext):
#     def process_a(self, item, data, depth, with_cutted):
#     def process_span(self, item, data, depth, with_cutted):
#     def process_li(self, item, data, depth, with_cutted):
#     def process_blockquote(self, item, data, depth, with_cutted):
#     def process_hr(self, item, data, depth, with_cutted):
#     def process_s(self, item, data, depth, with_cutted):
# def htmlToString(node, with_cutted=True, fancy=True, vk_links=False, hr_lines=True, disable_links=False):
# def node2string(node, encoding="utf-8"):
# def mon2num(s):
# def is_cut(item):
# def find_images(body, spoiler_title=True, no_other=False):
# def encode_multipart_formdata(fields, files, boundary=None):
# def get_content_type(filename):
# def send_form(url, fields, files, timeout=None, headers=None):
# def find_substring(s, start, end, extend=False, with_start=True, with_end=True):
# def download(url, maxmem=20 * 1024 * 1024, timeout=5, waitout=15, headers=None):
# def find_good_image(urls, maxmem=20 * 1024 * 1024):
# def generate_comments_tree(comms):
# def parse_avatar_url(url):
# def decode_cf_email(data):
# def decode_cf_email_for_link(m):
# def replace_cloudflare_emails(data):
# def normalize_body(body=None, raw_body=None, cls='text'):
# def html_escape(s, single_quote=False):
# def escape_topic_contents(data, may_be_short=False):
# def escape_comment_contents(data):
# def escape_blog_content(data):
# def escape_profile_content(data):
# def parse_datetime(s, utc=True):
# def gen_user_agent():
# def get_cookies_dict(headers):
# def is_module_available(name):
# def build_proxy_params(proxy=None):
# class HTMLFormatter(object):
#     NEWLINE = -1
#     L = []


# Path: test/test_utils_cfemails.py
import pytest
from tabun_api import utils


    '<a href="mailto:почта@ya.ru">почта@ya.ru</a>',
), (
    'link_href_attrs',
    '<a title="1" href="/cdn-cgi/l/email-protection#1bcba4cba5ca9cca99cbab5b7e6d7e69626b74756235696e" target="_blank">foo</a><br/>',
    '<a title="1" href="mailto:почта@everypony.ru" target="_blank">foo</a><br/>',
), (
    'link_href_attrs_text',
    '<a title="1" href="/cdn-cgi/l/email-protection#d1016e016f00560053016191b4a7b4a3a8a1bebfa8ffa3a4" target="_blank"><span class="__cf_email__" data-cfemail="d0a0bfb3b8a4b190b5a6b5a2a9a0bfbea9fea2a5">[email&#160;protected]</span></a>',
    '<a title="1" href="mailto:почта@everypony.ru" target="_blank">pochta@everypony.ru</a>',
), (
    'text',
    '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="572738343f233617322132252e2738392e792522">[email&#160;protected]</a>',
    'pochta@everypony.ru',
)]


@pytest.mark.parametrize(
    'input_html,output_html',
    [pytest.param(*x[1:], id=x[0]) for i, x in enumerate(test_cases)]
)
def test_replace_cloudflare_emails_unicode(input_html, output_html):
    assert utils.replace_cloudflare_emails(input_html.encode('utf-8')) == output_html.encode('utf-8')


@pytest.mark.parametrize(
    'input_html,output_html',
    [pytest.param(*x[1:], id=x[0]) for i, x in enumerate(test_cases)]
)
def test_replace_cloudflare_emails_bytes(input_html, output_html):

    assert utils.replace_cloudflare_emails(input_html.encode('utf-8')) == output_html.encode('utf-8')