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

TST: started refactoring the tests

parent ef8d6f66
No related branches found
No related tags found
2 merge requests!108Release 0.5.0,!104Create a new scanner module and move functions from crawl module there
Pipeline #34414 failed
......@@ -74,16 +74,17 @@ def dircheckstr(*pathcomponents):
@pytest.fixture
def crawler():
crawler = Crawler(debug=True)
crawler.crawl_directory(rfp("test_directories", "examples_article"),
crawler = Crawler()
crawled_data, debug_tree = crawler.crawl_directory(
rfp("test_directories", "examples_article"),
rfp("scifolder_cfood.yml"))
return crawler
return crawler, crawled_data, debug_tree
@pytest.fixture
def ident(crawler):
ident = LocalStorageIdentifiableAdapter()
crawler.identifiableAdapter = ident
crawler[0].identifiableAdapter = ident
# The records.xml file is constructed as follows:
# To a full run of the crawler, resolve all identifiables and insert all resulting entities.
......@@ -112,8 +113,11 @@ def ident(crawler):
def test_record_structure_generation(crawler):
# TODO How does this test relate to the test function in test_scalars_cfood with the same name?
# There seems to be code duplication
subd = crawler.debug_tree[dircheckstr("DataAnalysis")]
subc = crawler.debug_metadata["copied"][dircheckstr("DataAnalysis")]
debug_tree = crawler[2]
subd = debug_tree.debug_tree[dircheckstr("DataAnalysis")]
subc = debug_tree.debug_metadata["copied"][dircheckstr("DataAnalysis")]
assert len(subd) == 2
# variables store on Data Analysis node of debug tree
assert len(subd[0]) == 4
......@@ -127,9 +131,9 @@ def test_record_structure_generation(crawler):
assert subd[0]["DataAnalysis"] == "examples_article/DataAnalysis"
assert subc[0]["DataAnalysis"] is False
subd = crawler.debug_tree[dircheckstr(
subd = debug_tree.debug_tree[dircheckstr(
"DataAnalysis", "2020_climate-model-predict")]
subc = crawler.debug_metadata["copied"][dircheckstr(
subc = debug_tree.debug_metadata["copied"][dircheckstr(
"DataAnalysis", "2020_climate-model-predict")]
assert len(subd[1]) == 1
......@@ -157,10 +161,10 @@ def test_record_structure_generation(crawler):
assert subc[0]["date"] is False
assert subc[0]["identifier"] is False
subd = crawler.debug_tree[dircheckstr("DataAnalysis",
subd = debug_tree.debug_tree[dircheckstr("DataAnalysis",
"2020_climate-model-predict",
"2020-02-08_prediction-errors")]
subc = crawler.debug_metadata["copied"][dircheckstr("DataAnalysis",
subc = debug_tree.debug_metadata["copied"][dircheckstr("DataAnalysis",
"2020_climate-model-predict",
"2020-02-08_prediction-errors")]
assert len(subd[0]) == 12
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment