diff --git a/src/caoscrawler/identifiable_adapters.py b/src/caoscrawler/identifiable_adapters.py index da8ebaf23c5071077c957f3155c8a64f7129653f..40c801547a85afaf32e1ab6a668bc47d98d60b66 100644 --- a/src/caoscrawler/identifiable_adapters.py +++ b/src/caoscrawler/identifiable_adapters.py @@ -27,6 +27,7 @@ from __future__ import annotations import yaml from datetime import datetime +from typing import Any from .identifiable import Identifiable import caosdb as db import logging @@ -35,14 +36,14 @@ from .utils import has_parent logger = logging.getLogger(__name__) -def convert_value(value): +def convert_value(value: Any): """ Returns a string representation of the value that is suitable to be used in the query looking for the identified record. Parameters ---------- - value : the value that shall be returned and potentially converted. + value : Any type, the value that shall be returned and potentially converted. Returns ------- diff --git a/unittests/test_identifiable_adapters.py b/unittests/test_identifiable_adapters.py index 06ea8cdfdb782d23baf5910837203d31d99c9e2a..c3b44e1c8e3775fc6e8b7118b82ffa6a20bef484 100644 --- a/unittests/test_identifiable_adapters.py +++ b/unittests/test_identifiable_adapters.py @@ -30,7 +30,7 @@ test identifiable_adapters module import os from datetime import datetime from caoscrawler.identifiable_adapters import ( - CaosDBIdentifiableAdapter, IdentifiableAdapter) + CaosDBIdentifiableAdapter, convert_value, IdentifiableAdapter) from caoscrawler.identifiable import Identifiable import caosdb as db @@ -99,3 +99,12 @@ def test_load_from_yaml_file(): assert project_i is not None assert project_i.get_property("project_id") is not None assert project_i.get_property("title") is not None + + +def test_convert_value(): + # test that string representation of objects stay unchanged. No stripping or so. + class A(): + def __repr__(self): + return " a " + + assert convert_value(A()) == " a "