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
34c14ea4
Commit
34c14ea4
authored
1 year ago
by
Manon Blanco
Browse files
Options
Downloads
Patches
Plain Diff
Parametrize `test_classifications`
parent
673b5cc1
No related branches found
No related tags found
No related merge requests found
Pipeline
#159904
passed
1 year ago
Stage: test
Stage: build
Stage: release
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_elements_worker/test_classifications.py
+379
-416
379 additions, 416 deletions
tests/test_elements_worker/test_classifications.py
with
379 additions
and
416 deletions
tests/test_elements_worker/test_classifications.py
+
379
−
416
View file @
34c14ea4
...
...
@@ -190,54 +190,145 @@ def test_retrieve_ml_class_not_in_cache(responses, mock_elements_worker):
]
def
test_create_classification_wrong_element
(
mock_elements_worker
):
with
pytest
.
raises
(
AssertionError
,
match
=
"
element shouldn
'
t be null and should be an Element or CachedElement
"
,
):
mock_elements_worker
.
create_classification
(
element
=
None
,
ml_class
=
"
a_class
"
,
confidence
=
0.42
,
high_confidence
=
True
,
)
with
pytest
.
raises
(
AssertionError
,
match
=
"
element shouldn
'
t be null and should be an Element or CachedElement
"
,
):
mock_elements_worker
.
create_classification
(
element
=
"
not element type
"
,
ml_class
=
"
a_class
"
,
confidence
=
0.42
,
high_confidence
=
True
,
)
@pytest.mark.parametrize
(
(
"
data
"
,
"
error_message
"
),
[
# Wrong element
(
{
"
element
"
:
None
,
"
ml_class
"
:
"
a_class
"
,
"
confidence
"
:
0.42
,
"
high_confidence
"
:
True
,
},
"
element shouldn
'
t be null and should be an Element or CachedElement
"
,
),
(
{
"
element
"
:
"
not element type
"
,
"
ml_class
"
:
"
a_class
"
,
"
confidence
"
:
0.42
,
"
high_confidence
"
:
True
,
},
"
element shouldn
'
t be null and should be an Element or CachedElement
"
,
),
# Wrong ml_class
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
ml_class
"
:
None
,
"
confidence
"
:
0.42
,
"
high_confidence
"
:
True
,
},
"
ml_class shouldn
'
t be null and should be of type str
"
,
),
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
ml_class
"
:
1234
,
"
confidence
"
:
0.42
,
"
high_confidence
"
:
True
,
},
"
ml_class shouldn
'
t be null and should be of type str
"
,
),
# Wrong confidence
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
ml_class
"
:
"
a_class
"
,
"
confidence
"
:
None
,
"
high_confidence
"
:
True
,
},
"
confidence shouldn
'
t be null and should be a float in [0..1] range
"
,
),
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
ml_class
"
:
"
a_class
"
,
"
confidence
"
:
"
wrong confidence
"
,
"
high_confidence
"
:
True
,
},
"
confidence shouldn
'
t be null and should be a float in [0..1] range
"
,
),
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
ml_class
"
:
"
a_class
"
,
"
confidence
"
:
0
,
"
high_confidence
"
:
True
,
},
"
confidence shouldn
'
t be null and should be a float in [0..1] range
"
,
),
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
ml_class
"
:
"
a_class
"
,
"
confidence
"
:
2.00
,
"
high_confidence
"
:
True
,
},
"
confidence shouldn
'
t be null and should be a float in [0..1] range
"
,
),
# Wrong high_confidence
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
ml_class
"
:
"
a_class
"
,
"
confidence
"
:
0.42
,
"
high_confidence
"
:
None
,
},
"
high_confidence shouldn
'
t be null and should be of type bool
"
,
),
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
ml_class
"
:
"
a_class
"
,
"
confidence
"
:
0.42
,
"
high_confidence
"
:
"
wrong high_confidence
"
,
},
"
high_confidence shouldn
'
t be null and should be of type bool
"
,
),
],
)
def
test_create_classification_wrong_data
(
data
,
error_message
,
mock_elements_worker
):
mock_elements_worker
.
classes
=
{
"
a_class
"
:
"
0000
"
}
with
pytest
.
raises
(
AssertionError
,
match
=
re
.
escape
(
error_message
)):
mock_elements_worker
.
create_classification
(
**
data
)
def
test_create_classification_wrong_ml_class
(
mock_elements_worker
,
responses
):
def
test_create_classification_api_error
(
responses
,
mock_elements_worker
):
mock_elements_worker
.
classes
=
{
"
a_class
"
:
"
0000
"
}
elt
=
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
})
responses
.
add
(
responses
.
POST
,
"
http://testserver/api/v1/classifications/
"
,
status
=
500
,
)
with
pytest
.
raises
(
AssertionError
,
match
=
"
ml_class shouldn
'
t be null and should be of type str
"
):
with
pytest
.
raises
(
ErrorResponse
):
mock_elements_worker
.
create_classification
(
element
=
elt
,
ml_class
=
None
,
ml_class
=
"
a_class
"
,
confidence
=
0.42
,
high_confidence
=
True
,
)
with
pytest
.
raises
(
AssertionError
,
match
=
"
ml_class shouldn
'
t be null and should be of type str
"
):
mock_elements_worker
.
create_classification
(
element
=
elt
,
ml_class
=
1234
,
confidence
=
0.42
,
high_confidence
=
True
,
)
assert
len
(
responses
.
calls
)
==
len
(
BASE_API_CALLS
)
+
5
assert
[
(
call
.
request
.
method
,
call
.
request
.
url
)
for
call
in
responses
.
calls
]
==
BASE_API_CALLS
+
[
# We retry 5 times the API call
(
"
POST
"
,
"
http://testserver/api/v1/classifications/
"
),
(
"
POST
"
,
"
http://testserver/api/v1/classifications/
"
),
(
"
POST
"
,
"
http://testserver/api/v1/classifications/
"
),
(
"
POST
"
,
"
http://testserver/api/v1/classifications/
"
),
(
"
POST
"
,
"
http://testserver/api/v1/classifications/
"
),
]
# Automatically create a missing class !
def
test_create_classification_create_ml_class
(
mock_elements_worker
,
responses
):
elt
=
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
})
# Automatically create a missing class!
responses
.
add
(
responses
.
POST
,
"
http://testserver/api/v1/corpus/11111111-1111-1111-1111-111111111111/classes/
"
,
...
...
@@ -283,119 +374,6 @@ def test_create_classification_wrong_ml_class(mock_elements_worker, responses):
]
def
test_create_classification_wrong_confidence
(
mock_elements_worker
):
mock_elements_worker
.
classes
=
{
"
a_class
"
:
"
0000
"
}
elt
=
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
})
with
pytest
.
raises
(
AssertionError
,
match
=
re
.
escape
(
"
confidence shouldn
'
t be null and should be a float in [0..1] range
"
),
):
mock_elements_worker
.
create_classification
(
element
=
elt
,
ml_class
=
"
a_class
"
,
confidence
=
None
,
high_confidence
=
True
,
)
with
pytest
.
raises
(
AssertionError
,
match
=
re
.
escape
(
"
confidence shouldn
'
t be null and should be a float in [0..1] range
"
),
):
mock_elements_worker
.
create_classification
(
element
=
elt
,
ml_class
=
"
a_class
"
,
confidence
=
"
wrong confidence
"
,
high_confidence
=
True
,
)
with
pytest
.
raises
(
AssertionError
,
match
=
re
.
escape
(
"
confidence shouldn
'
t be null and should be a float in [0..1] range
"
),
):
mock_elements_worker
.
create_classification
(
element
=
elt
,
ml_class
=
"
a_class
"
,
confidence
=
0
,
high_confidence
=
True
,
)
with
pytest
.
raises
(
AssertionError
,
match
=
re
.
escape
(
"
confidence shouldn
'
t be null and should be a float in [0..1] range
"
),
):
mock_elements_worker
.
create_classification
(
element
=
elt
,
ml_class
=
"
a_class
"
,
confidence
=
2.00
,
high_confidence
=
True
,
)
def
test_create_classification_wrong_high_confidence
(
mock_elements_worker
):
mock_elements_worker
.
classes
=
{
"
a_class
"
:
"
0000
"
}
elt
=
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
})
with
pytest
.
raises
(
AssertionError
,
match
=
"
high_confidence shouldn
'
t be null and should be of type bool
"
,
):
mock_elements_worker
.
create_classification
(
element
=
elt
,
ml_class
=
"
a_class
"
,
confidence
=
0.42
,
high_confidence
=
None
,
)
with
pytest
.
raises
(
AssertionError
,
match
=
"
high_confidence shouldn
'
t be null and should be of type bool
"
,
):
mock_elements_worker
.
create_classification
(
element
=
elt
,
ml_class
=
"
a_class
"
,
confidence
=
0.42
,
high_confidence
=
"
wrong high_confidence
"
,
)
def
test_create_classification_api_error
(
responses
,
mock_elements_worker
):
mock_elements_worker
.
classes
=
{
"
a_class
"
:
"
0000
"
}
elt
=
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
})
responses
.
add
(
responses
.
POST
,
"
http://testserver/api/v1/classifications/
"
,
status
=
500
,
)
with
pytest
.
raises
(
ErrorResponse
):
mock_elements_worker
.
create_classification
(
element
=
elt
,
ml_class
=
"
a_class
"
,
confidence
=
0.42
,
high_confidence
=
True
,
)
assert
len
(
responses
.
calls
)
==
len
(
BASE_API_CALLS
)
+
5
assert
[
(
call
.
request
.
method
,
call
.
request
.
url
)
for
call
in
responses
.
calls
]
==
BASE_API_CALLS
+
[
# We retry 5 times the API call
(
"
POST
"
,
"
http://testserver/api/v1/classifications/
"
),
(
"
POST
"
,
"
http://testserver/api/v1/classifications/
"
),
(
"
POST
"
,
"
http://testserver/api/v1/classifications/
"
),
(
"
POST
"
,
"
http://testserver/api/v1/classifications/
"
),
(
"
POST
"
,
"
http://testserver/api/v1/classifications/
"
),
]
def
test_create_classification
(
responses
,
mock_elements_worker
):
mock_elements_worker
.
classes
=
{
"
a_class
"
:
"
0000
"
}
elt
=
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
})
...
...
@@ -519,278 +497,263 @@ def test_create_classification_duplicate_worker_run(responses, mock_elements_wor
}
def
test_create_classifications_wrong_element
(
mock_elements_worker
):
with
pytest
.
raises
(
AssertionError
,
match
=
"
element shouldn
'
t be null and should be an Element or CachedElement
"
,
):
mock_elements_worker
.
create_classifications
(
element
=
None
,
classifications
=
[
{
"
ml_class_id
"
:
"
uuid1
"
,
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
"
uuid2
"
,
"
confidence
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
)
with
pytest
.
raises
(
AssertionError
,
match
=
"
element shouldn
'
t be null and should be an Element or CachedElement
"
,
):
mock_elements_worker
.
create_classifications
(
element
=
"
not element type
"
,
classifications
=
[
{
"
ml_class_id
"
:
"
uuid1
"
,
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
"
uuid2
"
,
"
confidence
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
)
def
test_create_classifications_wrong_classifications
(
mock_elements_worker
):
elt
=
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
})
with
pytest
.
raises
(
AssertionError
,
match
=
"
classifications shouldn
'
t be null and should be of type list
"
,
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
None
,
)
with
pytest
.
raises
(
AssertionError
,
match
=
"
classifications shouldn
'
t be null and should be of type list
"
,
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
1234
,
)
with
pytest
.
raises
(
AssertionError
,
match
=
"
Classification at index 1 in classifications: ml_class_id shouldn
'
t be null and should be of type str
"
,
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
)
with
pytest
.
raises
(
AssertionError
,
match
=
"
Classification at index 1 in classifications: ml_class_id shouldn
'
t be null and should be of type str
"
,
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
None
,
"
confidence
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
)
with
pytest
.
raises
(
AssertionError
,
match
=
"
Classification at index 1 in classifications: ml_class_id shouldn
'
t be null and should be of type str
"
,
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
1234
,
"
confidence
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
)
with
pytest
.
raises
(
ValueError
,
match
=
"
Classification at index 1 in classifications: ml_class_id is not a valid uuid.
"
,
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
"
not_an_uuid
"
,
"
confidence
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
)
with
pytest
.
raises
(
AssertionError
,
match
=
re
.
escape
(
"
Classification at index 1 in classifications: confidence shouldn
'
t be null and should be a float in [0..1] range
"
@pytest.mark.parametrize
(
(
"
data
"
,
"
error_message
"
,
"
error_type
"
),
[
# Wrong element
(
{
"
element
"
:
None
,
"
classifications
"
:
[
{
"
ml_class_id
"
:
"
uuid1
"
,
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
"
uuid2
"
,
"
confidence
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
},
"
element shouldn
'
t be null and should be an Element or CachedElement
"
,
AssertionError
,
),
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
high_confidence
"
:
False
,
},
],
)
with
pytest
.
raises
(
AssertionError
,
match
=
re
.
escape
(
"
Classification at index 1 in classifications: confidence shouldn
'
t be null and should be a float in [0..1] range
"
(
{
"
element
"
:
"
not element type
"
,
"
classifications
"
:
[
{
"
ml_class_id
"
:
"
uuid1
"
,
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
"
uuid2
"
,
"
confidence
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
},
"
element shouldn
'
t be null and should be an Element or CachedElement
"
,
AssertionError
,
),
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
None
,
"
high_confidence
"
:
False
,
},
],
)
with
pytest
.
raises
(
AssertionError
,
match
=
re
.
escape
(
"
Classification at index 1 in classifications: confidence shouldn
'
t be null and should be a float in [0..1] range
"
# Wrong classifications
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
None
,
},
"
classifications shouldn
'
t be null and should be of type list
"
,
AssertionError
,
),
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
"
wrong confidence
"
,
"
high_confidence
"
:
False
,
},
],
)
with
pytest
.
raises
(
AssertionError
,
match
=
re
.
escape
(
"
Classification at index 1 in classifications: confidence shouldn
'
t be null and should be a float in [0..1] range
"
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
1234
,
},
"
classifications shouldn
'
t be null and should be of type list
"
,
AssertionError
,
),
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0
,
"
high_confidence
"
:
False
,
},
],
)
with
pytest
.
raises
(
AssertionError
,
match
=
re
.
escape
(
"
Classification at index 1 in classifications: confidence shouldn
'
t be null and should be a float in [0..1] range
"
# Wrong classifications > ml_class_id
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
},
"
Classification at index 1 in classifications: ml_class_id shouldn
'
t be null and should be of type str
"
,
AssertionError
,
),
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
2.00
,
"
high_confidence
"
:
False
,
},
],
)
with
pytest
.
raises
(
AssertionError
,
match
=
re
.
escape
(
"
Classification at index 1 in classifications: high_confidence should be of type bool
"
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
None
,
"
confidence
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
},
"
Classification at index 1 in classifications: ml_class_id shouldn
'
t be null and should be of type str
"
,
AssertionError
,
),
):
mock_elements_worker
.
create_classifications
(
element
=
elt
,
classifications
=
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.25
,
"
high_confidence
"
:
"
wrong high_confidence
"
,
},
],
)
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
1234
,
"
confidence
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
},
"
Classification at index 1 in classifications: ml_class_id shouldn
'
t be null and should be of type str
"
,
AssertionError
,
),
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
"
not_an_uuid
"
,
"
confidence
"
:
0.25
,
"
high_confidence
"
:
False
,
},
],
},
"
Classification at index 1 in classifications: ml_class_id is not a valid uuid.
"
,
ValueError
,
),
# Wrong classifications > confidence
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
high_confidence
"
:
False
,
},
],
},
"
Classification at index 1 in classifications: confidence shouldn
'
t be null and should be a float in [0..1] range
"
,
AssertionError
,
),
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
None
,
"
high_confidence
"
:
False
,
},
],
},
"
Classification at index 1 in classifications: confidence shouldn
'
t be null and should be a float in [0..1] range
"
,
AssertionError
,
),
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
"
wrong confidence
"
,
"
high_confidence
"
:
False
,
},
],
},
"
Classification at index 1 in classifications: confidence shouldn
'
t be null and should be a float in [0..1] range
"
,
AssertionError
,
),
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0
,
"
high_confidence
"
:
False
,
},
],
},
"
Classification at index 1 in classifications: confidence shouldn
'
t be null and should be a float in [0..1] range
"
,
AssertionError
,
),
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
2.00
,
"
high_confidence
"
:
False
,
},
],
},
"
Classification at index 1 in classifications: confidence shouldn
'
t be null and should be a float in [0..1] range
"
,
AssertionError
,
),
# Wrong classifications > high_confidence
(
{
"
element
"
:
Element
({
"
id
"
:
"
12341234-1234-1234-1234-123412341234
"
}),
"
classifications
"
:
[
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.75
,
"
high_confidence
"
:
False
,
},
{
"
ml_class_id
"
:
str
(
uuid4
()),
"
confidence
"
:
0.25
,
"
high_confidence
"
:
"
wrong high_confidence
"
,
},
],
},
"
Classification at index 1 in classifications: high_confidence should be of type bool
"
,
AssertionError
,
),
],
)
def
test_create_classifications_wrong_data
(
data
,
error_message
,
error_type
,
mock_elements_worker
):
with
pytest
.
raises
(
error_type
,
match
=
re
.
escape
(
error_message
)):
mock_elements_worker
.
create_classifications
(
**
data
)
def
test_create_classifications_api_error
(
responses
,
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