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
e23c86a5
Commit
e23c86a5
authored
1 year ago
by
Yoann Schneider
Browse files
Options
Downloads
Patches
Plain Diff
Check before updating image, better tests
parent
a2470c0f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex_worker/worker/element.py
+2
-1
2 additions, 1 deletion
arkindex_worker/worker/element.py
tests/test_elements_worker/test_elements.py
+39
-9
39 additions, 9 deletions
tests/test_elements_worker/test_elements.py
with
41 additions
and
10 deletions
arkindex_worker/worker/element.py
+
2
−
1
View file @
e23c86a5
...
...
@@ -343,7 +343,8 @@ class ElementMixin(object):
payload
[
"
polygon
"
]
=
str
(
payload
[
"
polygon
"
])
# Retrieve the right image
payload
[
"
image
"
]
=
CachedImage
.
get_by_id
(
payload
[
"
image
"
])
if
"
image
"
in
payload
:
payload
[
"
image
"
]
=
CachedImage
.
get_by_id
(
payload
[
"
image
"
])
CachedElement
.
update
(
**
payload
).
where
(
CachedElement
.
id
==
element
.
id
...
...
This diff is collapsed.
Click to expand it.
tests/test_elements_worker/test_elements.py
+
39
−
9
View file @
e23c86a5
...
...
@@ -1306,8 +1306,37 @@ def test_update_element_api_error(responses, mock_elements_worker):
]
@pytest.mark.parametrize
(
"
payload
"
,
(
(
{
"
polygon
"
:
[[
10
,
10
],
[
20
,
20
],
[
20
,
10
],
[
10
,
20
]],
"
confidence
"
:
None
,
}
),
(
{
"
rotation_angle
"
:
45
,
"
mirrored
"
:
False
,
}
),
(
{
"
polygon
"
:
[[
10
,
10
],
[
20
,
20
],
[
20
,
10
],
[
10
,
20
]],
"
confidence
"
:
None
,
"
rotation_angle
"
:
45
,
"
mirrored
"
:
False
,
}
),
),
)
def
test_update_element
(
responses
,
mock_elements_worker_with_cache
,
mock_cached_elements
,
mock_cached_images
responses
,
mock_elements_worker_with_cache
,
mock_cached_elements
,
mock_cached_images
,
payload
,
):
elt
=
CachedElement
.
select
().
first
()
new_image
=
CachedImage
.
select
().
first
()
...
...
@@ -1315,11 +1344,8 @@ def test_update_element(
elt_response
=
{
"
type
"
:
"
new type
"
,
"
name
"
:
"
new name
"
,
"
polygon
"
:
[[
10
,
10
],
[
20
,
20
],
[
20
,
10
],
[
10
,
20
]],
"
confidence
"
:
None
,
"
rotation_angle
"
:
45
,
"
mirrored
"
:
False
,
"
image
"
:
str
(
new_image
.
id
),
**
payload
,
}
responses
.
add
(
responses
.
PUT
,
...
...
@@ -1347,12 +1373,16 @@ def test_update_element(
assert
element_update_response
==
elt_response
cached_element
=
CachedElement
.
get
(
CachedElement
.
id
==
elt
.
id
)
# Always present in payload
assert
cached_element
.
type
==
elt_response
[
"
type
"
]
assert
cached_element
.
polygon
==
str
(
elt_response
[
"
polygon
"
])
assert
cached_element
.
confidence
==
elt_response
[
"
confidence
"
]
assert
cached_element
.
rotation_angle
==
elt_response
[
"
rotation_angle
"
]
assert
cached_element
.
mirrored
==
elt_response
[
"
mirrored
"
]
assert
str
(
cached_element
.
image_id
)
==
elt_response
[
"
image
"
]
# Optional params
if
"
polygon
"
in
payload
:
# Cast to string as this is the only difference compared to model
elt_response
[
"
polygon
"
]
=
str
(
elt_response
[
"
polygon
"
])
for
param
in
payload
:
assert
getattr
(
cached_element
,
param
)
==
elt_response
[
param
]
def
test_update_element_confidence
(
...
...
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