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
Merge requests
!206
Helper for ListCorpusEntities
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Helper for ListCorpusEntities
helper-for-list-corpus-entities
into
master
Overview
6
Commits
16
Pipelines
1
Changes
1
All threads resolved!
Hide all comments
Merged
Thibault Lavigne
requested to merge
helper-for-list-corpus-entities
into
master
2 years ago
Overview
6
Commits
16
Pipelines
1
Changes
1
All threads resolved!
Hide all comments
Expand
Closes
#131 (closed)
Requires
!209 (merged)
Edited
2 years ago
by
Yoann Schneider
0
0
Merge request reports
Viewing commit
5ef8923d
Prev
Next
Show latest version
1 file
+
20
−
5
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Verified
5ef8923d
Modif code with the review
· 5ef8923d
NolanB
authored
2 years ago
tests/test_elements_worker/test_entities.py
+
57
−
0
Options
@@ -654,3 +654,60 @@ def test_list_transcription_entities(fake_dummy_worker):
assert
len
(
fake_dummy_worker
.
api_client
.
history
)
==
1
assert
len
(
fake_dummy_worker
.
api_client
.
responses
)
==
0
def
test_list_corpus_entities
(
responses
,
mock_elements_worker
):
corpus_id
=
"
11111111-1111-1111-1111-111111111111
"
responses
.
add
(
responses
.
GET
,
f
"
http://testserver/api/v1/corpus/
{
corpus_id
}
/entities/
"
,
json
=
{
"
count
"
:
1
,
"
next
"
:
None
,
"
results
"
:
[
{
"
id
"
:
"
fake_entity_id
"
,
}
],
},
)
# list is required to actually do the request
assert
list
(
mock_elements_worker
.
list_corpus_entities
())
==
[
{
"
id
"
:
"
fake_entity_id
"
,
}
]
assert
len
(
responses
.
calls
)
==
len
(
BASE_API_CALLS
)
+
1
assert
[
(
call
.
request
.
method
,
call
.
request
.
url
)
for
call
in
responses
.
calls
]
==
BASE_API_CALLS
+
[
(
"
GET
"
,
f
"
http://testserver/api/v1/corpus/
{
corpus_id
}
/entities/
"
,
),
]
@pytest.mark.parametrize
(
"
wrong_name
"
,
[
1234
,
12.5
,
],
)
def
test_list_corpus_entities_wrong_name
(
mock_elements_worker
,
wrong_name
):
with
pytest
.
raises
(
AssertionError
)
as
e
:
mock_elements_worker
.
list_corpus_entities
(
name
=
wrong_name
)
assert
str
(
e
.
value
)
==
"
name should be of type str
"
@pytest.mark.parametrize
(
"
wrong_parent
"
,
[{
"
id
"
:
"
element_id
"
},
12.5
,
"
blabla
"
],
)
def
test_list_corpus_entities_wrong_parent
(
mock_elements_worker
,
wrong_parent
):
with
pytest
.
raises
(
AssertionError
)
as
e
:
mock_elements_worker
.
list_corpus_entities
(
parent
=
wrong_parent
)
assert
str
(
e
.
value
)
==
"
parent should be of type Element
"
Loading