From 8d3334acd954ccb532ec863b48a9e96a8371d7cc Mon Sep 17 00:00:00 2001 From: Daniel <d.hornung@indiscale.com> Date: Tue, 20 Feb 2024 12:12:40 +0100 Subject: [PATCH] WIP TEST: TDD tests for #87: Handle long strings more gracefully --- integrationtests/test_issues.py | 34 ++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/integrationtests/test_issues.py b/integrationtests/test_issues.py index 441edac5..2ec772a2 100644 --- a/integrationtests/test_issues.py +++ b/integrationtests/test_issues.py @@ -18,22 +18,24 @@ # from pytest import fixture, mark -import caosdb as db -from caosdb.cached import cache_clear +import linkahead as db +from linkahead.cached import cache_clear from caosadvancedtools.models.parser import parse_model_from_string from caoscrawler.crawl import Crawler +from caoscrawler.identifiable import Identifiable from caoscrawler.identifiable_adapters import CaosDBIdentifiableAdapter from caoscrawler.structure_elements import DictElement from caoscrawler.scanner import create_converter_registry, scan_structure_elements -from caosdb.utils.register_tests import clear_database, set_test_key +from linkahead.utils.register_tests import clear_database, set_test_key set_test_key("10b128cf8a1372f30aa3697466bb55e76974e0c16a599bb44ace88f19c8f61e2") @fixture(autouse=True) def clear_cache(): + """Clear the LinkAhead cache.""" cache_clear() @@ -266,3 +268,29 @@ Campaign: # Nothing to do for the existing ents assert len(ups) == 0 assert ins[0].name == event.name + + +def test_indiscale_87(clear_database): + """Handle long string queries gracefully. + + https://gitlab.com/linkahead/linkahead-crawler/-/issues/87 + """ + + prop = db.Property(name="str", datatype=db.TEXT).insert() + rt = db.RecordType(name="RT1").add_property(prop).insert() + strings = [ + "0123456789" * 26, + "0" * 260, + "0123456789" * 25 + "9876543210", + ] + recs = [ + db.Record().add_parent(rt).add_property(name="str", value=string).insert() + for string in strings + ] + idents = [ + Identifiable(record_type="RT1", properties={"str": string}) + for string in strings + ] + adapter = CaosDBIdentifiableAdapter() + for rec, ident in zip(recs, idents): + assert adapter.retrieve_identified_record_for_identifiable(ident) == rec -- GitLab