Skip to content
Snippets Groups Projects
Verified Commit 8d3334ac authored by Daniel Hornung's avatar Daniel Hornung
Browse files

WIP TEST: TDD tests for #87: Handle long strings more gracefully

parent ffc93747
Branches
Tags
2 merge requests!160STY: styling,!155Mitigation of server problem with long strings as POV values
Checking pipeline status
...@@ -18,22 +18,24 @@ ...@@ -18,22 +18,24 @@
# #
from pytest import fixture, mark from pytest import fixture, mark
import caosdb as db import linkahead as db
from caosdb.cached import cache_clear from linkahead.cached import cache_clear
from caosadvancedtools.models.parser import parse_model_from_string from caosadvancedtools.models.parser import parse_model_from_string
from caoscrawler.crawl import Crawler from caoscrawler.crawl import Crawler
from caoscrawler.identifiable import Identifiable
from caoscrawler.identifiable_adapters import CaosDBIdentifiableAdapter from caoscrawler.identifiable_adapters import CaosDBIdentifiableAdapter
from caoscrawler.structure_elements import DictElement from caoscrawler.structure_elements import DictElement
from caoscrawler.scanner import create_converter_registry, scan_structure_elements 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") set_test_key("10b128cf8a1372f30aa3697466bb55e76974e0c16a599bb44ace88f19c8f61e2")
@fixture(autouse=True) @fixture(autouse=True)
def clear_cache(): def clear_cache():
"""Clear the LinkAhead cache."""
cache_clear() cache_clear()
...@@ -266,3 +268,29 @@ Campaign: ...@@ -266,3 +268,29 @@ Campaign:
# Nothing to do for the existing ents # Nothing to do for the existing ents
assert len(ups) == 0 assert len(ups) == 0
assert ins[0].name == event.name 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment