# Path: tests/unit/transforms/helpers.py
# def run_transform(key, value, content):
#     pipeline = transform_factory({'transform': [{key: value}]})
#     return pipeline(True, content)
# 
# HTML = u"""<?xml version="1.0" encoding="utf-8"?>
# <html>
#     <body>
#         <h2 class="header nav">
#             <a href="page.html" id="page-link">Page</a>
#         </h2>
#         <div id="content">
#             Привет, Мир!
#         </div>
#         <div class="footer">
#             Footer content
#         </div>
#     </body>
# </html>
# """


import pytest
from .helpers import run_transform, HTML
# -*- coding: utf-8 -*-



@pytest.mark.parametrize("selector,expected", [
    pytest.param('boolean(//body/h2/a)', 'True', id='boolean'),
    pytest.param("count(//div)", "2.0", id="float"),
    pytest.param("string(//a)", "Page", id="string"),
    pytest.param("//body/h2/a/@href", "page.html", id="attribute"),
    pytest.param(
        '//body/h2/a[@id="page-link"]',
        '<a href="page.html" id="page-link">Page</a>',
        id='element'
    ),
    pytest.param(
        '/html/namespace::*[name()]',
        'xml="http://www.w3.org/XML/1998/namespace"',
        id='namespace'
    ),
])
def test_xpath_selector(selector, expected):

# Path: tests/unit/transforms/helpers.py
# def run_transform(key, value, content):
#     pipeline = transform_factory({'transform': [{key: value}]})
#     return pipeline(True, content)
# 
# HTML = u"""<?xml version="1.0" encoding="utf-8"?>
# <html>
#     <body>
#         <h2 class="header nav">
#             <a href="page.html" id="page-link">Page</a>
#         </h2>
#         <div id="content">
#             Привет, Мир!
#         </div>
#         <div class="footer">
#             Footer content
#         </div>
#     </body>
# </html>
# """


# Path: tests/unit/transforms/test_xpath.py
import pytest
from .helpers import run_transform, HTML

# -*- coding: utf-8 -*-



@pytest.mark.parametrize("selector,expected", [
    pytest.param('boolean(//body/h2/a)', 'True', id='boolean'),
    pytest.param("count(//div)", "2.0", id="float"),
    pytest.param("string(//a)", "Page", id="string"),
    pytest.param("//body/h2/a/@href", "page.html", id="attribute"),
    pytest.param(
        '//body/h2/a[@id="page-link"]',
        '<a href="page.html" id="page-link">Page</a>',
        id='element'
    ),
    pytest.param(
        '/html/namespace::*[name()]',
        'xml="http://www.w3.org/XML/1998/namespace"',
        id='namespace'
    ),
])
def test_xpath_selector(selector, expected):

    ok, content = run_transform('xpath', selector, HTML)