Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Base Worker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
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
Workers
Base Worker
Commits
2f2e425e
Commit
2f2e425e
authored
3 years ago
by
Eva Bardou
Committed by
Bastien Abadie
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Support giving a CachedElement to create_entity function
parent
67788703
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!92
Support giving a CachedElement to create_entity function
Pipeline
#78480
passed
3 years ago
Stage: test
Stage: build
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex_worker/worker/entity.py
+3
-2
3 additions, 2 deletions
arkindex_worker/worker/entity.py
tests/test_elements_worker/test_entities.py
+8
-2
8 additions, 2 deletions
tests/test_elements_worker/test_entities.py
with
11 additions
and
4 deletions
arkindex_worker/worker/entity.py
+
3
−
2
View file @
2f2e425e
...
...
@@ -4,6 +4,7 @@
from
enum
import
Enum
from
arkindex_worker
import
logger
from
arkindex_worker.cache
import
CachedElement
from
arkindex_worker.models
import
Element
...
...
@@ -24,8 +25,8 @@ class EntityMixin(object):
Return the ID of the created entity
"""
assert
element
and
isinstance
(
element
,
Element
),
"
element shouldn
'
t be null and should be
of type
Element
"
element
,
(
Element
,
CachedElement
)
),
"
element shouldn
'
t be null and should be
an Element or Cached
Element
"
assert
name
and
isinstance
(
name
,
str
),
"
name shouldn
'
t be null and should be of type str
"
...
...
This diff is collapsed.
Click to expand it.
tests/test_elements_worker/test_entities.py
+
8
−
2
View file @
2f2e425e
...
...
@@ -16,7 +16,10 @@ def test_create_entity_wrong_element(mock_elements_worker):
type
=
EntityType
.
Person
,
corpus
=
"
12341234-1234-1234-1234-123412341234
"
,
)
assert
str
(
e
.
value
)
==
"
element shouldn
'
t be null and should be of type Element
"
assert
(
str
(
e
.
value
)
==
"
element shouldn
'
t be null and should be an Element or CachedElement
"
)
with
pytest
.
raises
(
AssertionError
)
as
e
:
mock_elements_worker
.
create_entity
(
...
...
@@ -25,7 +28,10 @@ def test_create_entity_wrong_element(mock_elements_worker):
type
=
EntityType
.
Person
,
corpus
=
"
12341234-1234-1234-1234-123412341234
"
,
)
assert
str
(
e
.
value
)
==
"
element shouldn
'
t be null and should be of type Element
"
assert
(
str
(
e
.
value
)
==
"
element shouldn
'
t be null and should be an Element or CachedElement
"
)
def
test_create_entity_wrong_name
(
mock_elements_worker
):
...
...
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