Skip to content
Snippets Groups Projects
Commit 7018a317 authored by Quazgar's avatar Quazgar
Browse files

Merge branch 'f-quotes-around-datetimes' into 'dev'

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` 

# Test Environment

Use an empty profile with server set to `f-quotes-around-datetimes` manually in `profile.yml`.

# Check List for the Author

Please, prepare your MR for a review. Be sure to write a summary and a
focus and create gitlab comments for the reviewer. They should guide the
reviewer through the changes, explain your changes and also point out open
questions. For further good practices have a look at [our review
guidelines](https://gitlab.com/caosdb/caosdb/-/blob/dev/REVIEW_GUIDELINES.md)

- [x] All automated tests pass
- [x] Reference related Issues
- [x] Up-to-date CHANGELOG.md
- [x] Annotations in code (Gitlab comments)
  - Intent of new code
  - Problems with old code
  - Why this implementation?


# Check List for the Reviewer


- [x] I understand the intent of this MR
- [ ] All automated tests pass
- [x] Up-to-date CHANGELOG.md
- [ ] The test environment setup works and the intended behavior is
  reproducible in the test environment
- [ ] In-code documentation and comments are up-to-date.
- [ ] Check: Are there spezifications? Are they satisfied?

For further good practices have a look at [our review guidelines](https://gitlab.com/caosdb/caosdb/-/blob/dev/REVIEW_GUIDELINES.md).

See merge request caosdb/caosdb-pyinttest!32
parents 494e2fa4 0d1462de
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Tests for [caosdb-server#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