Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def jinja_transform(code, content, conf=None):
return JinjaTransform(code, conf or {})(content)
def jinja_transform(code, content, conf=None):
return JinjaTransform(code, conf or {})(content)
def test_missing_config_raises_configuration_error(exists):
with pytest.raises(ConfigurationError):
settings()
def test_browser_xpath(target, html_text_conf):
html_text_conf['transform'].insert(0, {
'xpath': './/*[@class="footer"]',
})
ok, content = Checker(html_text_conf).check()
assert ok is True
assert content == 'Footer content'
def test_python_script_sample(python_script_conf):
ok, content = Checker(python_script_conf).check()
assert ok is True
assert content == "python"
def test_browser_css(target, html_text_conf):
html_text_conf['transform'].insert(0, {
'css': '.footer',
})
ok, content = Checker(html_text_conf).check()
assert ok is True
assert content == 'Footer content'
def test_valid_http_404(target, not_found_conf):
not_found_conf.update({
'valid_http': [404],
})
ok, content = Checker(not_found_conf).check()
assert ok is True
assert '404' in content
def test_tag_transformer(target, html_text_conf):
html_text_conf['transform'].insert(0, {
'tag': 'div',
})
ok, content = Checker(html_text_conf).check()
assert ok is True
assert content == 'Hello world!'
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'}
],
# 'scenario': 'import pdb; pdb.set_trace()',
'transform': [{'css': '.unclosed-tag > #params'}, 'text'],
# 'headless': False,
}
ok, content = Checker(conf).check()
assert ok is True
assert content == "\n".join([
"name = aemn",
"pass = password",
])
def test_simple_fetcher_with_pretty_json(target, json_conf):
ok, content = Checker(json_conf).check()
assert ok is True
assert content == (
'{\n'
' "first name": "Peter",\n'