Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Merge requests
!1037
Remove source field from creation endpoints
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Remove source field from creation endpoints
remove-sources
into
master
Overview
2
Commits
11
Pipelines
0
Changes
6
Merged
Valentin Rigal
requested to merge
remove-sources
into
master
4 years ago
Overview
2
Commits
11
Pipelines
0
Changes
6
Expand
0
0
Merge request reports
Viewing commit
adf1e4b9
Prev
Next
Show latest version
6 files
+
104
−
588
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
6
Search (e.g. *.vue) (Ctrl+P)
adf1e4b9
Update tests for documents app
· adf1e4b9
Valentin Rigal
authored
4 years ago
arkindex/documents/tests/test_bulk_classification.py
+
1
−
66
Options
@@ -62,71 +62,6 @@ class TestBulkClassification(FixtureAPITestCase):
}
)
def
test_bulk_classification_requires_source_xor_worker_version
(
self
):
"""
A classifier data source XOR a worker_version is required to push classifications on an element
"""
wrong_payloads
=
(
{
'
classifier
'
:
self
.
src
.
slug
,
'
worker_version
'
:
self
.
worker_version
.
id
},
{
'
classifier
'
:
None
,
'
worker_version
'
:
None
},
{
'
classifier
'
:
''
},
{}
)
self
.
client
.
force_login
(
self
.
user
)
for
payload
in
wrong_payloads
:
response
=
self
.
client
.
post
(
reverse
(
'
api:classification-bulk
'
),
format
=
'
json
'
,
data
=
{
'
parent
'
:
str
(
self
.
page
.
id
),
'
classifications
'
:
[{
'
class_name
'
:
'
cat
'
,
'
confidence
'
:
0.42
}],
**
payload
}
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
if
payload
.
get
(
'
classifier
'
)
and
payload
.
get
(
'
worker_version
'
):
self
.
assertDictEqual
(
response
.
json
(),
{
'
classifier
'
:
[
'
This field XOR worker_version field must be set to create classifications
'
],
'
worker_version
'
:
[
'
This field XOR classifier field must be set to create classifications
'
]
})
def
test_bulk_classification_source
(
self
):
"""
Bulk classifications are created using an existing classifier source
"""
self
.
client
.
force_login
(
self
.
user
)
with
self
.
assertNumQueries
(
8
):
response
=
self
.
client
.
post
(
reverse
(
'
api:classification-bulk
'
),
format
=
'
json
'
,
data
=
{
"
parent
"
:
str
(
self
.
page
.
id
),
"
classifier
"
:
self
.
src
.
slug
,
"
classifications
"
:
[{
"
class_name
"
:
'
dog
'
,
"
confidence
"
:
0.99
,
"
high_confidence
"
:
True
},
{
"
class_name
"
:
'
cat
'
,
"
confidence
"
:
0.42
,
}]
}
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_201_CREATED
)
self
.
assertCountEqual
(
list
(
self
.
page
.
classifications
.
values_list
(
'
ml_class__name
'
,
'
confidence
'
,
'
high_confidence
'
,
'
source
'
,
'
worker_version
'
)),
[
(
'
dog
'
,
0.99
,
True
,
self
.
src
.
id
,
None
),
(
'
cat
'
,
0.42
,
False
,
self
.
src
.
id
,
None
)
],
)
def
test_bulk_classification_worker_version
(
self
):
"""
Classifications are created and linked to a worker version
@@ -255,5 +190,5 @@ class TestBulkClassification(FixtureAPITestCase):
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_400_BAD_REQUEST
)
self
.
assertDictEqual
(
response
.
json
(),
{
'
classifications
'
:
[
'
Duplicated ML classes are not allowed from the same
source or
worker version.
'
]
'
classifications
'
:
[
'
Duplicated ML classes are not allowed from the same worker version.
'
]
})
Loading