Skip to content
Snippets Groups Projects
Commit 475a663c authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: remove another rfp and debugging output

parent eb50f875
No related branches found
No related tags found
2 merge requests!123REL: Release v0.6.0,!113F refactor test tool
Pipeline #36641 failed
......@@ -26,38 +26,35 @@
an integration test module that does basic integration tests
"""
from caosadvancedtools.crawler import Crawler as OldCrawler
from caoscrawler.debug_tree import DebugTree
import os
from caosdb import EmptyUniqueQueryError
import argparse
import os
import sys
from argparse import RawTextHelpFormatter
from pathlib import Path
import caosdb as db
import pytest
import yaml
from caosadvancedtools.crawler import Crawler as OldCrawler
from caosadvancedtools.models.parser import parse_model_from_yaml
from caoscrawler import Crawler, SecurityMode
from caoscrawler.debug_tree import DebugTree
from caoscrawler.identifiable import Identifiable
import caosdb as db
from caoscrawler.identifiable_adapters import CaosDBIdentifiableAdapter
from caoscrawler.scanner import scan_directory
import pytest
from caosadvancedtools.models.parser import parse_model_from_yaml
import yaml
from caosdb import EmptyUniqueQueryError
from caosdb.utils.register_tests import clear_database, set_test_key
set_test_key("10b128cf8a1372f30aa3697466bb55e76974e0c16a599bb44ace88f19c8f61e2")
#TODO move test related stuff here and remove it from unittests
# TODO move test related stuff here and remove it from unittests
def rfp(*pathcomponents):
"""
Return full path.
Shorthand convenience function.
"""
return os.path.join(os.path.dirname(__file__), *pathcomponents)
UNITTESTDIR = Path(__file__).parent.parent.parent / "unittests"
@pytest.fixture
def usemodel():
model = parse_model_from_yaml(rfp("model.yml"))
model = parse_model_from_yaml(UNITTESTDIR / "model.yml")
model.sync_data_model(noquestion=True, verbose=False)
......@@ -88,8 +85,8 @@ def ident():
def crawl_standard_test_directory(subdir: str = "examples_article",
cfood: str = "scifolder_cfood.yml",
debug_tree=None):
return scan_directory(rfp("..", "..", "unittests", "test_directories", subdir),
rfp("..", "..", "unittests", cfood),
return scan_directory(UNITTESTDIR / "test_directories" / subdir,
UNITTESTDIR / cfood,
debug_tree=debug_tree)
......@@ -110,7 +107,7 @@ def crawler_extended(ident):
# correct paths for current working directory
file_list = [r for r in crawled_data if r.role == "File"]
for f in file_list:
f.file = rfp("..", "..", "unittests", "test_directories", f.file)
f.file = UNITTESTDIR / "test_directories" / f.file
return cr, crawled_data, debug_tree
......@@ -132,7 +129,7 @@ def test_single_insertion(clear_database, usemodel, crawler, ident):
if res[i].parents[0].name == "PyTestInfo":
del res[i]
# uncomment this to recreate the `records.xml` file
# filename = rfp("..", "..", "unittests", "records.xml")
# filename = UNITTESTDIR/ "records.xml"
# with open(filename, "w") as f:
# xml = res.to_xml()
# # Remove noscript and transaction benchmark:
......@@ -146,8 +143,8 @@ def test_single_insertion(clear_database, usemodel, crawler, ident):
# Do a second run on the same data, there should be no changes:
crawler = Crawler(identifiableAdapter=ident)
crawled_data = scan_directory(rfp("../../unittests/test_directories", "examples_article"),
rfp("../../unittests/scifolder_cfood.yml"))
crawled_data = scan_directory(UNITTESTDIR/"test_directories", "examples_article",
UNITTESTDIR/"scifolder_cfood.yml")
ins, ups = crawler.synchronize(crawled_data=crawled_data)
assert len(ins) == 0
assert len(ups) == 0
......@@ -215,7 +212,6 @@ def test_insertion_and_update(clear_database, usemodel, ident, crawler):
cr = Crawler(identifiableAdapter=ident)
crawled_data = crawl_standard_test_directory("example_overwrite_1")
# cr.save_debug_data(rfp("provenance.yml"))
assert len(crawled_data) == 3
ins, ups = cr.synchronize(crawled_data=crawled_data)
assert len(ins) == 0
......@@ -318,7 +314,7 @@ def test_file_update(clear_database, usemodel, ident, crawler_extended):
file_list = [r for r in crawled_data if r.role == "File"]
for f in file_list:
f.file = rfp("..", "..", "unittests", "test_directories", f.file)
f.file = UNITTESTDIR / "test_directories", f.file
ins2, ups2 = cr.synchronize(crawled_data=crawled_data, commit_changes=True)
assert len(ups1) == 0
assert len(ups2) == 0
......@@ -333,7 +329,7 @@ def test_file_update(clear_database, usemodel, ident, crawler_extended):
file_list = [r for r in crawled_data if r.role == "File"]
for f in file_list:
f.file = rfp("..", "..", "unittests", "test_directories", f.file)
f.file = UNITTESTDIR / "test_directories", f.file
ins3, ups3 = cr2.synchronize(crawled_data=crawled_data, commit_changes=True)
assert len(ups3) == 11
......
......@@ -146,10 +146,6 @@ def test_crawl_csv_table():
rfp("test_directories", "examples_tables", "crawler_for_tables.yml"),
debug_tree=dbt)
for file_ext in ["xlsx", "csv"]:
print(dbt.debug_tree)
print(dircheckstr(
UNITTESTDIR / "test_directories" / "examples_tables" / "ExperimentalData",
"test1." + file_ext))
subd = dbt.debug_tree[dircheckstr(
UNITTESTDIR / "test_directories" / "examples_tables" / "ExperimentalData",
"test1." + file_ext)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment