diff --git a/integrationtests/test.py b/integrationtests/test.py index 7b5a43afdc3558ee1ba053665cfb776b65b48087..8e62daeb19c587ba90d550f417e51754d93a23ad 100755 --- a/integrationtests/test.py +++ b/integrationtests/test.py @@ -36,6 +36,7 @@ import caosdb as db from newcrawler.identifiable_adapters import CaosDBIdentifiableAdapter import pytest from caosadvancedtools.models.parser import parse_model_from_yaml +import yaml import os @@ -60,10 +61,21 @@ def not_test_record(r: db.Record): return True def register_test(): - info = str(db.Info()) - if "without" not in info: - raise RuntimeError("This instance of CaosDB contains entities already." - "It must be empty in order to gegister a new test.") + info = db.Info() + for info_element in info.messages: + if info_element.startswith("<Counts>"): + counts = yaml.load(info_element[8:-9], Loader=yaml.SafeLoader) + for count_element in ['records', + 'properties', + 'recordTypes', + 'files', + 'fssize']: + if counts[count_element] > 0: + raise RuntimeError("This instance of CaosDB contains entities already." + "It must be empty in order to gegister a new test.") + break + else: + raise RuntimeError("Response from server for Info could not be interpreted.") answer = input("This method will register your current test with key {} with the currently" " running instance of CaosDB. Do you want to continue (y/N)?".format(