From b1b9cedda14a1cfd1c410af57ec2979c76b0188d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <henrik@trineo.org> Date: Wed, 22 May 2019 16:32:48 +0200 Subject: [PATCH] MAINT: added Tests and doc --- src/caosadvancedtools/utils.py | 2 ++ unittests/test_utils.py | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/caosadvancedtools/utils.py b/src/caosadvancedtools/utils.py index 4fd569a1..b030a6c2 100644 --- a/src/caosadvancedtools/utils.py +++ b/src/caosadvancedtools/utils.py @@ -76,6 +76,8 @@ def find_file_included_by(glob): """ Executes a query that looks for files included by a glob. The glob needs to be according to CaosDB rules. + + Returns a container. """ query_string = "FIND file which is stored at {}".format(glob) diff --git a/unittests/test_utils.py b/unittests/test_utils.py index 1b93eebe..24082d47 100644 --- a/unittests/test_utils.py +++ b/unittests/test_utils.py @@ -21,10 +21,9 @@ # # ** end header import unittest -from tempfile import NamedTemporaryFile -import caosdb as db -from caosadvancedtools.utils import assure_absolute_path_in_glob +from caosadvancedtools.utils import (assure_absolute_path_in_glob, + string_to_person) class Assure_absoluteTest(unittest.TestCase): @@ -37,3 +36,22 @@ class Assure_absoluteTest(unittest.TestCase): def test_compress(self): assert assure_absolute_path_in_glob("../leute", "/Data") == "/leute" + + +def is_dhornung(rec): + if (rec.get_property("firstname").value == "Daniel" + and rec.get_property("lastname").value == "Hornung"): + + return True + + return False + + +class PersonParserTest(unittest.TestCase): + def test_simple(self): + rec = string_to_person("Daniel Hornung") + assert is_dhornung(rec) + rec = string_to_person("Daniel Hornung (MPI)") + assert is_dhornung(rec) + rec = string_to_person("Henrik tom Wörden (MPI)") + assert not is_dhornung(rec) -- GitLab