Skip to content
Snippets Groups Projects
Commit 0d1462de authored by Florian Spreckelsen's avatar Florian Spreckelsen Committed by Quazgar
Browse files

Tests for quotes around datetimes

# Summary

Adds a test for checking queries with quoted datetimes. See [#39](https://gitlab.com/caosdb/caosdb-server/-/issues/39) in caosdb-server.

# Focus

`test_issue_39` in `tests/test_issues_server.py`
parent ae4f5662
Branches
Tags
No related merge requests found
......@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Tests for [#62](https://gitlab.com/caosdb/caosdb-server/-/issues/62)
in caosdb-server-project, i.e., renaming of a RecordType that should
be reflected in properties with that RT as datatype.
- Test for [#39](https://gitlab.com/caosdb/caosdb-server/-/issues/39)
in caosdb server which checks if quoted datetimes in queries are
evaluated correctly.
### Changed (for changes in existing functionality)
......
......@@ -25,13 +25,13 @@
"""Tests for issues on gitlab.com, project caosdb-server."""
import caosdb as db
from caosdb.exceptions import EntityError
from caosdb.exceptions import EntityError, TransactionError
import pytest
def setup_module():
try:
db.execute_query("FIND ENTITY WITH ID > 100").delete()
db.execute_query("FIND ENTITY WITH ID > 99").delete()
except Exception as delete_exc:
print(delete_exc)
......@@ -48,6 +48,27 @@ def teardown():
# ########################### Issue tests start here #####################
def test_issue_39():
"""Query Language Bug - quotes around year
Test for https://gitlab.com/caosdb/caosdb-server/-/issues/39
"""
date_str = "2020-01-01"
prop_name = "Test_Date"
db.Property(name=prop_name, datatype=db.DATETIME).insert()
db.RecordType(name="Test_Type").add_property(name=prop_name).insert()
db.Record(name="Test_Record").add_parent(name="Test_Type").add_property(
name=prop_name, value=date_str).insert()
# Quotes around years should work in the query
ent = db.execute_query("FIND entity WITH A Test_Date IN \"2020\"",
unique=True)
assert ent.get_property(prop_name).value == date_str
# This should raise a transaction error
with pytest.raises(TransactionError):
db.execute_query("FIND entity WITH A Test_Date IN \"abcd\"")
@pytest.mark.xfail(reason="to be fixed in server repo")
def test_issue_62():
"""datatype is not changed when recordtype name changes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment