Skip to content
Snippets Groups Projects
Commit 874caa27 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

TST: unit test for CrawlerTemplate

parent 7cb33452
No related branches found
No related tags found
2 merge requests!178FIX: #96 Better error output for crawl.py script.,!169Umlaut in cfood
Checking pipeline status
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
from pytest import mark from pytest import mark
from caoscrawler.converters import replace_variables from caoscrawler.converters import replace_variables, CrawlerTemplate
from caoscrawler.crawl import Crawler from caoscrawler.crawl import Crawler
from caoscrawler.structure_elements import DictElement from caoscrawler.structure_elements import DictElement
...@@ -128,3 +128,16 @@ def test_issue_93(): ...@@ -128,3 +128,16 @@ def test_issue_93():
# Without braces # Without braces
for exp in expressions: for exp in expressions:
assert replace_variables(f"${exp}", values) == f"This is {exp}" assert replace_variables(f"${exp}", values) == f"This is {exp}"
def test_crawler_template():
temp = CrawlerTemplate("$bla")
assert temp.safe_substitute(**{"bla": "test"}) == "test"
# Umlauts are not replaced, because they are not contained
# in the CrawlerTemplate's braceidpattern:
temp = CrawlerTemplate("$blä")
assert temp.safe_substitute(**{"blä": "test"}) == "$blä"
temp = CrawlerTemplate("${blä}")
assert temp.safe_substitute(**{"blä": "test"}) == "${blä}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment