diff --git a/src/caoscrawler/converters.py b/src/caoscrawler/converters.py index 460331699eff4721a8263e916010885f224d3345..f316eba6096356511192005d5628ae4657a07454 100644 --- a/src/caoscrawler/converters.py +++ b/src/caoscrawler/converters.py @@ -163,7 +163,7 @@ def handle_value(value: Union[dict, str, list], values: GeneralStore): propvalue.append(replace_variables(element, values)) else: propvalue.append(element) - + return (propvalue, collection_mode) else: # value is another simple type diff --git a/unittests/test_scalars_cfood.py b/unittests/test_scalars_cfood.py index 57e8ccc4d7804b9d915715e3a8df9e860f988fb0..1bf8f0b7d67f00f2018b5b68424d6b9cc17602eb 100644 --- a/unittests/test_scalars_cfood.py +++ b/unittests/test_scalars_cfood.py @@ -3,44 +3,15 @@ # https://gitlab.com/caosdb/caosdb-crawler/-/issues/9 # A. Schlemmer, 06/2021 -from caoscrawler.crawl import Crawler, SecurityMode -from caoscrawler.structure_elements import File, DictTextElement, DictListElement -from caoscrawler.identifiable_adapters import IdentifiableAdapter, LocalStorageIdentifiableAdapter -from simulated_server_data import full_data -from functools import partial -from copy import deepcopy -from unittest.mock import patch -import caosdb.common.models as dbmodels -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 # The main function that is affected by this issue: from caoscrawler.converters import handle_value +from caoscrawler.crawl import Crawler # We need the store for the above function from caoscrawler.stores import GeneralStore - -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 ("caoscrawler.structure_elements.Directory: " + basename( - join(*pathcomponents)) + ", " + rfp( - "test_directories", "examples_article", *pathcomponents)) +from test_tool import dircheckstr, rfp @pytest.fixture @@ -58,7 +29,7 @@ def test_handle_value(): # This one should work: assert handle_value("bla", store) == ("bla", "single") - # These ones will currently fail: + # These failed: assert handle_value(4, store) == (4, "single") assert handle_value(4.2, store) == (4.2, "single") assert handle_value(True, store) == (True, "single") @@ -66,6 +37,7 @@ def test_handle_value(): # List test: assert handle_value([4, 3, 2], store) == ([4, 3, 2], "single") + def test_record_structure_generation(crawler): subd = crawler.debug_tree[dircheckstr("DataAnalysis")] assert len(subd) == 2 @@ -78,9 +50,8 @@ def test_record_structure_generation(crawler): prop = subd[0]["RecordThatGetsParentsLater"].get_property("someId") assert type(prop.value) == int assert prop.value == 23 - + # record store on Data Analysis node of debug tree assert len(subd[1]) == 1 - prop2 = subd[0]["RecordThatGetsParentsLater"].get_property("someId") + prop2 = subd[1]["RecordThatGetsParentsLater"].get_property("someId") assert prop == prop2 -