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

TST: added unit tests for variable substitution based on Templates

parent 3e70e214
No related branches found
No related tags found
2 merge requests!53Release 0.1,!21F use substitution templates
Pipeline #22871 failed
ExperimentalData: # name of the converter
type: Directory
match: ExperimentalData
subtree:
File: # name of the converter
type: SimpleFile
match: (?P<year>[0-9]{2,2})(?P<month>[0-9]{2,2})(?P<day>[0-9]{2,2})_data.dat
records:
Experiment:
date: 20$year-$month-$day
#!/bin/python
# Tests for variable substitutions
# A. Schlemmer, 05/2022
from newcrawler import Crawler
from newcrawler.structure_elements import File, DictTextElement, DictListElement
from newcrawler.identifiable_adapters import IdentifiableAdapter, LocalStorageIdentifiableAdapter
from functools import partial
from copy import deepcopy
from unittest.mock import MagicMock, Mock
from os.path import join, dirname, basename
import yaml
import caosdb as db
from caosdb.apiutils import compare_entities
import pytest
from pytest import raises
def rfp(*pathcomponents):
"""
Return full path.
Shorthand convenience function.
"""
return join(dirname(__file__), *pathcomponents)
def dircheckstr(*pathcomponents):
"""
Return the debug tree identifier for a given path.
"""
return "newcrawler.structure_elements.Directory: " + basename(join(*pathcomponents)) + ", " + rfp("test_directories", "example_substitutions", *pathcomponents)
@pytest.fixture
def crawler():
crawler = Crawler(debug=True)
crawler.crawl_directory(rfp("test_directories", "example_substitutions", "ExperimentalData"),
rfp("test_directories", "example_substitutions", "substitutions.yml"))
return crawler
def test_substitutions(crawler):
subd = crawler.debug_tree[dircheckstr("ExperimentalData")]
breakpoint()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment