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
3d811871
Commit
3d811871
authored
1 year ago
by
Yoann Schneider
Browse files
Options
Downloads
Patches
Plain Diff
one function per param
parent
5664a432
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_elements_worker/test_elements.py
+127
-1
127 additions, 1 deletion
tests/test_elements_worker/test_elements.py
with
127 additions
and
1 deletion
tests/test_elements_worker/test_elements.py
+
127
−
1
View file @
3d811871
...
...
@@ -1222,10 +1222,63 @@ def test_create_elements_integrity_error(
{
"
element
"
:
"
not element type
"
},
"
element shouldn
'
t be null and should be an Element or CachedElement
"
,
),
))
def
test_partial_update_element_wrong_param_element
(
mock_elements_worker
,
payload
,
error
):
api_payload
=
{
"
element
"
:
Element
({
"
zone
"
:
None
}),
**
payload
,
}
with
pytest
.
raises
(
AssertionError
)
as
e
:
mock_elements_worker
.
partial_update_element
(
**
api_payload
,
)
assert
str
(
e
.
value
)
==
error
@pytest.mark.parametrize
(
"
payload, error
"
,
(
# Type
({
"
type
"
:
1234
},
"
type should be a str
"
),
),
)
def
test_partial_update_element_wrong_param_type
(
mock_elements_worker
,
payload
,
error
):
api_payload
=
{
"
element
"
:
Element
({
"
zone
"
:
None
}),
**
payload
,
}
with
pytest
.
raises
(
AssertionError
)
as
e
:
mock_elements_worker
.
partial_update_element
(
**
api_payload
,
)
assert
str
(
e
.
value
)
==
error
@pytest.mark.parametrize
(
"
payload, error
"
,
(
# Name
({
"
name
"
:
1234
},
"
name should be a str
"
),
)
)
def
test_partial_update_element_wrong_param_name
(
mock_elements_worker
,
payload
,
error
):
api_payload
=
{
"
element
"
:
Element
({
"
zone
"
:
None
}),
**
payload
,
}
with
pytest
.
raises
(
AssertionError
)
as
e
:
mock_elements_worker
.
partial_update_element
(
**
api_payload
,
)
assert
str
(
e
.
value
)
==
error
@pytest.mark.parametrize
(
"
payload, error
"
,
(
# Polygon
({
"
polygon
"
:
"
not a polygon
"
},
"
polygon should be a list
"
),
({
"
polygon
"
:
[[
1
,
1
],
[
2
,
2
]]},
"
polygon should have at least three points
"
),
...
...
@@ -1241,6 +1294,24 @@ def test_create_elements_integrity_error(
{
"
polygon
"
:
[[
"
not a coord
"
,
1
],
[
2
,
2
],
[
2
,
1
],
[
1
,
2
]]},
"
polygon points should be lists of two numbers
"
,
),
)
)
def
test_partial_update_element_wrong_param_polygon
(
mock_elements_worker
,
payload
,
error
):
api_payload
=
{
"
element
"
:
Element
({
"
zone
"
:
None
}),
**
payload
,
}
with
pytest
.
raises
(
AssertionError
)
as
e
:
mock_elements_worker
.
partial_update_element
(
**
api_payload
,
)
assert
str
(
e
.
value
)
==
error
@pytest.mark.parametrize
(
"
payload, error
"
,
(
# Confidence
({
"
confidence
"
:
"
lol
"
},
"
confidence should be None or a float in [0..1] range
"
),
({
"
confidence
"
:
"
0.2
"
},
"
confidence should be None or a float in [0..1] range
"
),
...
...
@@ -1250,19 +1321,74 @@ def test_create_elements_integrity_error(
{
"
confidence
"
:
float
(
"
inf
"
)},
"
confidence should be None or a float in [0..1] range
"
,
),
)
)
def
test_partial_update_element_wrong_param_conf
(
mock_elements_worker
,
payload
,
error
):
api_payload
=
{
"
element
"
:
Element
({
"
zone
"
:
None
}),
**
payload
,
}
with
pytest
.
raises
(
AssertionError
)
as
e
:
mock_elements_worker
.
partial_update_element
(
**
api_payload
,
)
assert
str
(
e
.
value
)
==
error
@pytest.mark.parametrize
(
"
payload, error
"
,
(
# Rotation angle
({
"
rotation_angle
"
:
"
lol
"
},
"
rotation_angle should be a positive integer
"
),
({
"
rotation_angle
"
:
-
1
},
"
rotation_angle should be a positive integer
"
),
({
"
rotation_angle
"
:
0.5
},
"
rotation_angle should be a positive integer
"
),
)
)
def
test_partial_update_element_wrong_param_rota
(
mock_elements_worker
,
payload
,
error
):
api_payload
=
{
"
element
"
:
Element
({
"
zone
"
:
None
}),
**
payload
,
}
with
pytest
.
raises
(
AssertionError
)
as
e
:
mock_elements_worker
.
partial_update_element
(
**
api_payload
,
)
assert
str
(
e
.
value
)
==
error
@pytest.mark.parametrize
(
"
payload, error
"
,
(
# Mirrored
({
"
mirrored
"
:
"
lol
"
},
"
mirrored should be a boolean
"
),
({
"
mirrored
"
:
1234
},
"
mirrored should be a boolean
"
),
)
)
def
test_partial_update_element_wrong_param_mir
(
mock_elements_worker
,
payload
,
error
):
api_payload
=
{
"
element
"
:
Element
({
"
zone
"
:
None
}),
**
payload
,
}
with
pytest
.
raises
(
AssertionError
)
as
e
:
mock_elements_worker
.
partial_update_element
(
**
api_payload
,
)
assert
str
(
e
.
value
)
==
error
@pytest.mark.parametrize
(
"
payload, error
"
,
(
# Image
({
"
image
"
:
"
lol
"
},
"
image should be a UUID
"
),
({
"
image
"
:
1234
},
"
image should be a UUID
"
),
),
)
def
test_partial_update_element_wrong_param
(
mock_elements_worker
,
payload
,
error
):
def
test_partial_update_element_wrong_param
_image
(
mock_elements_worker
,
payload
,
error
):
api_payload
=
{
"
element
"
:
Element
({
"
zone
"
:
None
}),
**
payload
,
...
...
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