# Path: kibitzr/checker.py
# class Checker(object):
#     def __init__(self, conf):
#         self.conf = conf
#         self.fetch = fetcher_factory(conf)
#         self.transform = transform_factory(self.conf)
#         self.notify = notify_factory(self.conf)
# 
#     @classmethod
#     def create_from_settings(cls, checks, names=None):
#         if names:
#             selected_checks = [
#                 conf
#                 for conf in checks
#                 if conf['name'] in names
#             ]
#             selected_names = [conf['name'] for conf in selected_checks]
#             if len(selected_checks) < len(checks):
#                 logger.info("Filtered list of checks to: %r",
#                             ", ".join(sorted(selected_names)))
#                 checks = selected_checks
#             if len(selected_names) < len(names):
#                 logger.error(
#                     "Following check(s) were not found: %r",
#                     ", ".join(sorted(set(names).difference(selected_names)))
#                 )
#         return [cls(conf)
#                 for conf in checks]
# 
#     def check(self):
#         ok, content = self.fetch()
#         ok, report = self.transform(ok, content)
#         self.notify(report=report)
#         return ok, report


from kibitzr.checker import Checker


def test_fill_form_sample(target):
    conf = {
        'name': 'Test page',
        'url': "http://{0}:{1}/form.html".format(*target),
        'form': [
            {'id': 'name', 'value': '{{ "name" | sort | join("") }}'},
            {'css': '#pass', 'creds': 'pass'}
        ],
        'transform': [
            # {'python': 'print(ok, content); content = content or ""'},
            {'css': '.unclosed-tag > #params'},
            'text',
        ],
        # 'headless': False,
    }

# Path: kibitzr/checker.py
# class Checker(object):
#     def __init__(self, conf):
#         self.conf = conf
#         self.fetch = fetcher_factory(conf)
#         self.transform = transform_factory(self.conf)
#         self.notify = notify_factory(self.conf)
# 
#     @classmethod
#     def create_from_settings(cls, checks, names=None):
#         if names:
#             selected_checks = [
#                 conf
#                 for conf in checks
#                 if conf['name'] in names
#             ]
#             selected_names = [conf['name'] for conf in selected_checks]
#             if len(selected_checks) < len(checks):
#                 logger.info("Filtered list of checks to: %r",
#                             ", ".join(sorted(selected_names)))
#                 checks = selected_checks
#             if len(selected_names) < len(names):
#                 logger.error(
#                     "Following check(s) were not found: %r",
#                     ", ".join(sorted(set(names).difference(selected_names)))
#                 )
#         return [cls(conf)
#                 for conf in checks]
# 
#     def check(self):
#         ok, content = self.fetch()
#         ok, report = self.transform(ok, content)
#         self.notify(report=report)
#         return ok, report


# Path: tests/simulation/test_forms.py
from kibitzr.checker import Checker



def test_fill_form_sample(target):
    conf = {
        'name': 'Test page',
        'url': "http://{0}:{1}/form.html".format(*target),
        'form': [
            {'id': 'name', 'value': '{{ "name" | sort | join("") }}'},
            {'css': '#pass', 'creds': 'pass'}
        ],
        'transform': [
            # {'python': 'print(ok, content); content = content or ""'},
            {'css': '.unclosed-tag > #params'},
            'text',
        ],
        # 'headless': False,
    }

    ok, content = Checker(conf).check()