Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
CaosDB Python Integration Tests
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Python Integration Tests
Commits
c1b70f54
Verified
Commit
c1b70f54
authored
5 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
WIP: tests for empty and null values
parent
fb9f1a4e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_empty_text_value.py
+63
-15
63 additions, 15 deletions
tests/test_empty_text_value.py
with
63 additions
and
15 deletions
tests/test_empty_text_value.py
+
63
−
15
View file @
c1b70f54
...
...
@@ -20,15 +20,15 @@
#
import
pytest
from
nose.tools
import
assert_equals
,
with_setup
import
caosdb
as
db
def
setup
():
rt
=
db
.
RecordType
(
"
Test
"
)
teardown
()
rt
=
db
.
RecordType
(
"
TestRT
"
)
rt
.
insert
()
p
=
db
.
Property
(
"
te
"
,
datatype
=
db
.
TEXT
)
p
=
db
.
Property
(
"
TestProp
"
,
datatype
=
db
.
TEXT
)
p
.
insert
()
...
...
@@ -37,24 +37,72 @@ def teardown():
db
.
execute_query
(
"
FIND Test*
"
).
delete
()
except
Exception
as
e
:
print
(
e
)
try
:
db
.
execute_query
(
"
FIND te
"
).
delete
()
except
Exception
as
e
:
print
(
e
)
@pytest.mark.skip
(
reason
=
"
this is the confirmation for https://gitlab.com/caosdb/caosdb-server/issues/33
"
)
@with_setup
(
setup
,
teardown
)
def
test_empty_string
():
r
=
db
.
Record
()
r
.
add_parent
(
"
Test
"
)
r
.
add_property
(
"
te
"
,
value
=
"
leer
"
)
r
.
add_parent
(
"
TestRT
"
)
r
.
add_property
(
"
TestProp
"
,
value
=
"
leer
"
)
r
.
insert
()
assert
db
.
execute_query
(
"
FIND TestRT with TestProp=
'
leer
'"
,
unique
=
True
).
id
==
r
.
id
r
.
delete
()
r
=
db
.
Record
()
r
.
add_parent
(
"
TestRT
"
)
r
.
add_property
(
"
TestProp
"
,
value
=
""
)
r
.
insert
()
assert
db
.
execute_query
(
"
FIND Record TestRT
"
,
unique
=
True
).
value
==
""
# assert db.execute_query("FIND TestRT with TestProp=''", unique=True).id == r.id
r
.
delete
()
def
test_null_value
():
r
=
db
.
Record
()
r
.
add_parent
(
"
TestRT
"
)
r
.
add_property
(
"
TestProp
"
,
value
=
"
null
"
)
r
.
insert
()
assert
db
.
execute_query
(
"
FIND TestRT with TestProp=
'
null
'"
,
unique
=
True
).
id
==
r
.
id
r
.
delete
()
r
=
db
.
Record
()
r
.
add_parent
(
"
TestRT
"
)
r
.
add_property
(
"
TestProp
"
,
value
=
None
)
r
.
insert
()
assert_equals
(
db
.
execute_query
(
"
FIND Test with te=
'
leer
'"
)[
0
].
id
,
r
.
id
)
assert
db
.
execute_query
(
"
FIND Record TestRT
"
,
unique
=
True
).
value
==
None
# assert db.execute_query("FIND TestRT WHERE TestProp IS NULL", unique=True).id == r.id
r
.
delete
()
def
test_list_with_empty_string
():
r
=
db
.
Record
()
r
.
add_parent
(
"
Test
"
)
r
.
add_property
(
"
te
"
,
value
=
""
)
r
.
add_parent
(
"
Test
RT
"
)
r
.
add_property
(
"
TestProp
"
,
datatype
=
db
.
LIST
(
db
.
TEXT
),
value
=
[
"
leer
"
]
)
r
.
insert
()
assert_equals
(
db
.
execute_query
(
"
FIND Test with te=
''"
)[
0
].
id
,
r
.
id
)
assert
len
(
db
.
execute_query
(
"
FIND Record TestRT
"
,
unique
=
True
).
value
)
==
1
assert
db
.
execute_query
(
"
FIND Record TestRT
"
,
unique
=
True
).
value
[
0
]
==
"
leer
"
# assert db.execute_query("FIND TestRT with TestProp='leer'", unique=True).id == r.id
r
.
delete
()
r
=
db
.
Record
()
r
.
add_parent
(
"
TestRT
"
)
r
.
add_property
(
"
TestProp
"
,
datatype
=
db
.
LIST
(
db
.
TEXT
),
value
=
[
""
])
r
.
insert
()
assert
len
(
db
.
execute_query
(
"
FIND Record TestRT
"
,
unique
=
True
).
value
)
==
1
assert
db
.
execute_query
(
"
FIND Record TestRT
"
,
unique
=
True
).
value
[
0
]
==
""
# assert db.execute_query("FIND TestRT with TestProp=''", unique=True).id == r.id
r
.
delete
()
def
test_list_with_null_value
():
r
=
db
.
Record
()
r
.
add_parent
(
"
TestRT
"
)
r
.
add_property
(
"
TestProp
"
,
datatype
=
db
.
LIST
(
db
.
TEXT
),
value
=
[
"
null
"
])
r
.
insert
()
assert
len
(
db
.
execute_query
(
"
FIND Record TestRT
"
,
unique
=
True
).
value
)
==
1
assert
db
.
execute_query
(
"
FIND Record TestRT
"
,
unique
=
True
).
value
[
0
]
==
"
null
"
assert
db
.
execute_query
(
"
FIND TestRT with TestProp=
'
null
'"
,
unique
=
True
).
id
==
r
.
id
r
.
delete
()
r
=
db
.
Record
()
r
.
add_parent
(
"
TestRT
"
)
r
.
add_property
(
"
TestProp
"
,
datatype
=
db
.
LIST
(
db
.
TEXT
),
value
=
[
None
])
r
.
insert
()
assert
len
(
db
.
execute_query
(
"
FIND Record TestRT
"
,
unique
=
True
).
value
)
==
1
assert
db
.
execute_query
(
"
FIND Record TestRT
"
,
unique
=
True
).
value
[
0
]
==
None
# assert db.execute_query("FIND TestRT WHERE TestProp IS NULL", unique=True).id == r.id
r
.
delete
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment