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

STY: autopep8 on test_scanner

parent 9e8cbc7c
No related branches found
No related tags found
2 merge requests!160STY: styling,!124More scifolder scanner unittests
Pipeline #38448 passed
...@@ -35,15 +35,15 @@ from utils import dircheckstr as dircheck_base ...@@ -35,15 +35,15 @@ from utils import dircheckstr as dircheck_base
UNITTESTDIR = Path(__file__).parent UNITTESTDIR = Path(__file__).parent
dircheckstr = partial(dircheck_base, UNITTESTDIR/"test_directories" / "examples_article") dircheckstr = partial(dircheck_base, UNITTESTDIR / "test_directories" / "examples_article")
def test_scan_structure_elements(): def test_scan_structure_elements():
tmpfi = NamedTemporaryFile(delete=False) tmpfi = NamedTemporaryFile(delete=False)
with open(UNITTESTDIR/"example_datastructure.yml", "r") as f: with open(UNITTESTDIR / "example_datastructure.yml", "r") as f:
data = yaml.load(f, Loader=yaml.SafeLoader) data = yaml.load(f, Loader=yaml.SafeLoader)
crawler_definition = load_definition(UNITTESTDIR/"example_cfood.yml") crawler_definition = load_definition(UNITTESTDIR / "example_cfood.yml")
converter_registry = create_converter_registry(crawler_definition) converter_registry = create_converter_registry(crawler_definition)
recs = scan_structure_elements(DictElement(name="", value=data), crawler_definition, recs = scan_structure_elements(DictElement(name="", value=data), crawler_definition,
converter_registry) converter_registry)
...@@ -54,10 +54,10 @@ def test_provenance_debug_data(): ...@@ -54,10 +54,10 @@ def test_provenance_debug_data():
# TODO rewrite the test to use a smaller example setup # TODO rewrite the test to use a smaller example setup
tmpfi = NamedTemporaryFile(delete=False) tmpfi = NamedTemporaryFile(delete=False)
debug_tree = DebugTree() debug_tree = DebugTree()
with open(UNITTESTDIR/"example_datastructure.yml", "r") as f: with open(UNITTESTDIR / "example_datastructure.yml", "r") as f:
data = yaml.load(f, Loader=yaml.SafeLoader) data = yaml.load(f, Loader=yaml.SafeLoader)
crawler_definition = load_definition(UNITTESTDIR/"example_cfood.yml") crawler_definition = load_definition(UNITTESTDIR / "example_cfood.yml")
converter_registry = create_converter_registry(crawler_definition) converter_registry = create_converter_registry(crawler_definition)
stuff = scan_structure_elements(DictElement(name="", value=data), crawler_definition, stuff = scan_structure_elements(DictElement(name="", value=data), crawler_definition,
converter_registry, debug_tree=debug_tree) converter_registry, debug_tree=debug_tree)
...@@ -83,8 +83,8 @@ def test_record_structure_generation(): ...@@ -83,8 +83,8 @@ def test_record_structure_generation():
# TODO test creation of debug information in a separate test # TODO test creation of debug information in a separate test
dbt = DebugTree() dbt = DebugTree()
scan_directory(UNITTESTDIR/"test_directories" / "examples_article", scan_directory(UNITTESTDIR / "test_directories" / "examples_article",
UNITTESTDIR/"scifolder_cfood.yml", UNITTESTDIR / "scifolder_cfood.yml",
debug_tree=dbt) debug_tree=dbt)
subd = dbt.debug_tree[dircheckstr("DataAnalysis")] subd = dbt.debug_tree[dircheckstr("DataAnalysis")]
subc = dbt.debug_metadata["copied"][dircheckstr("DataAnalysis")] subc = dbt.debug_metadata["copied"][dircheckstr("DataAnalysis")]
...@@ -174,13 +174,13 @@ def test_record_generation(): ...@@ -174,13 +174,13 @@ def test_record_generation():
Test the correct list of returned records by the scanner using the Test the correct list of returned records by the scanner using the
scifolder example from the article. scifolder example from the article.
""" """
records = scan_directory(UNITTESTDIR/"test_directories" / "examples_article", records = scan_directory(UNITTESTDIR / "test_directories" / "examples_article",
UNITTESTDIR/"scifolder_cfood.yml") UNITTESTDIR / "scifolder_cfood.yml")
def parent_filter(parent_name): def parent_filter(parent_name):
return [p for p in records if len(p.parents) == 1 and p.parents[0].name == parent_name] return [p for p in records if len(p.parents) == 1 and p.parents[0].name == parent_name]
def check_properties(records, check_props, check_additional=True): def check_properties(records, check_props, check_additional=True):
records_found = [0 for r in check_props] records_found = [0 for r in check_props]
for rec in records: for rec in records:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment