Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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 Crawler
Commits
8ad58963
Commit
8ad58963
authored
2 years ago
by
Henrik tom Wörden
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: do not allow name in properties
parent
4edb80e6
No related branches found
No related tags found
2 merge requests
!91
Release 0.3
,
!67
MAINT: introduce an identifiable class
Pipeline
#30764
passed
2 years ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/identifiable.py
+5
-2
5 additions, 2 deletions
src/caoscrawler/identifiable.py
unittests/test_identifiable.py
+6
-0
6 additions, 0 deletions
unittests/test_identifiable.py
with
11 additions
and
2 deletions
src/caoscrawler/identifiable.py
+
5
−
2
View file @
8ad58963
...
@@ -49,10 +49,13 @@ class Identifiable():
...
@@ -49,10 +49,13 @@ class Identifiable():
def
__init__
(
self
,
record_id
:
int
=
None
,
path
:
str
=
None
,
record_type
:
str
=
None
,
def
__init__
(
self
,
record_id
:
int
=
None
,
path
:
str
=
None
,
record_type
:
str
=
None
,
name
:
str
=
None
,
properties
:
dict
=
None
,
name
:
str
=
None
,
properties
:
dict
=
None
,
backrefs
:
list
[
Union
[
int
,
str
]]
=
None
):
backrefs
:
list
[
Union
[
int
,
str
]]
=
None
):
if
(
record_id
is
None
and
path
is
None
and
name
is
None
and
backrefs
is
None
and
(
properties
if
(
record_id
is
None
and
path
is
None
and
name
is
None
and
backrefs
is
None
and
(
is
None
or
len
(
properties
)
==
0
)):
properties
is
None
or
len
(
properties
)
==
0
)):
raise
ValueError
(
"
There is no identifying information. You need to add a path or
"
raise
ValueError
(
"
There is no identifying information. You need to add a path or
"
"
properties or other identifying attributes.
"
)
"
properties or other identifying attributes.
"
)
if
properties
is
not
None
and
'
name
'
in
[
k
.
lower
()
for
k
in
properties
.
keys
()]:
raise
ValueError
(
"
Please use the separete
'
name
'
keyword instead of the properties
"
"
dict for name
"
)
self
.
record_id
=
record_id
self
.
record_id
=
record_id
self
.
path
=
path
self
.
path
=
path
self
.
record_type
=
record_type
self
.
record_type
=
record_type
...
...
This diff is collapsed.
Click to expand it.
unittests/test_identifiable.py
+
6
−
0
View file @
8ad58963
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
test identifiable module
test identifiable module
"""
"""
import
pytest
import
caosdb
as
db
import
caosdb
as
db
from
caoscrawler.identifiable
import
Identifiable
from
caoscrawler.identifiable
import
Identifiable
from
caoscrawler.identified_cache
import
IdentifiedCache
from
caoscrawler.identified_cache
import
IdentifiedCache
...
@@ -59,6 +60,11 @@ def test_create_hashable_string():
...
@@ -59,6 +60,11 @@ def test_create_hashable_string():
Identifiable
(
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
db
.
Record
()]})))
Identifiable
(
record_type
=
"
B
"
,
properties
=
{
'
a
'
:
[
db
.
Record
()]})))
def
test_name
():
with
pytest
.
raises
(
ValueError
):
Identifiable
(
properties
=
{
"
Name
"
:
'
li
'
})
def
test_equality
():
def
test_equality
():
assert
Identifiable
(
assert
Identifiable
(
record_id
=
12
,
properties
=
{
"
a
"
:
0
})
==
Identifiable
(
record_id
=
12
,
properties
=
{
"
a
"
:
1
})
record_id
=
12
,
properties
=
{
"
a
"
:
0
})
==
Identifiable
(
record_id
=
12
,
properties
=
{
"
a
"
:
1
})
...
...
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