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
65b2e5df
Verified
Commit
65b2e5df
authored
2 years ago
by
Yoann Schneider
Browse files
Options
Downloads
Patches
Plain Diff
fix typo, remove any useless code from tests and use setup_api_client instead of configure
parent
f4b50a4b
No related branches found
No related tags found
No related merge requests found
Pipeline
#79502
passed
2 years ago
Stage: test
Stage: build
Stage: release
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex_worker/worker/element.py
+2
-2
2 additions, 2 deletions
arkindex_worker/worker/element.py
tests/test_elements_worker/test_elements.py
+4
-12
4 additions, 12 deletions
tests/test_elements_worker/test_elements.py
with
6 additions
and
14 deletions
arkindex_worker/worker/element.py
+
2
−
2
View file @
65b2e5df
...
...
@@ -12,7 +12,7 @@ from arkindex_worker import logger
from
arkindex_worker.cache
import
CachedElement
,
CachedImage
from
arkindex_worker.models
import
Corpus
,
Element
ElementType
=
NamedTuple
(
"
ElemenType
"
,
name
=
str
,
slug
=
str
,
is_folder
=
bool
)
ElementType
=
NamedTuple
(
"
Elemen
t
Type
"
,
name
=
str
,
slug
=
str
,
is_folder
=
bool
)
class
MissingTypeError
(
Exception
):
...
...
@@ -78,7 +78,7 @@ class ElementMixin(object):
)
else
:
raise
MissingTypeError
(
f
'
Element type(s)
{
"
,
"
.
join
(
sorted
(
missing_slugs
))
}
were not found in the
{
corpus
[
"
name
"
]
}
corpus (
{
corpus
[
"
id
"
]
}
).
'
f
'
Element type(s)
{
"
,
"
.
join
(
sorted
(
missing_slugs
))
}
were not found in the
{
corpus
.
name
}
corpus (
{
corpus
.
id
}
).
'
)
return
True
...
...
This diff is collapsed.
Click to expand it.
tests/test_elements_worker/test_elements.py
+
4
−
12
View file @
65b2e5df
...
...
@@ -34,11 +34,7 @@ def test_check_required_types_argument_types(mock_elements_worker):
assert
str
(
e
.
value
)
==
"
Element type slugs must be strings.
"
def
test_check_required_types
(
monkeypatch
,
tmp_path
,
mock_elements_worker
,
responses
):
elements_path
=
tmp_path
/
"
elements.json
"
elements_path
.
write_text
(
"
[]
"
)
monkeypatch
.
setenv
(
"
TASK_ELEMENTS
"
,
str
(
elements_path
))
def
test_check_required_types
(
responses
):
corpus_id
=
"
12341234-1234-1234-1234-123412341234
"
responses
.
add
(
responses
.
GET
,
...
...
@@ -50,7 +46,7 @@ def test_check_required_types(monkeypatch, tmp_path, mock_elements_worker, respo
},
)
worker
=
ElementsWorker
()
worker
.
configure
()
worker
.
setup_api_client
()
assert
worker
.
check_required_types
(
corpus_id
,
"
page
"
)
assert
worker
.
check_required_types
(
corpus_id
,
"
page
"
,
"
folder
"
)
...
...
@@ -63,11 +59,7 @@ def test_check_required_types(monkeypatch, tmp_path, mock_elements_worker, respo
)
def
test_create_missing_types
(
monkeypatch
,
tmp_path
,
mock_elements_worker
,
responses
):
elements_path
=
tmp_path
/
"
elements.json
"
elements_path
.
write_text
(
"
[]
"
)
monkeypatch
.
setenv
(
"
TASK_ELEMENTS
"
,
str
(
elements_path
))
def
test_create_missing_types
(
responses
):
corpus_id
=
"
12341234-1234-1234-1234-123412341234
"
responses
.
add
(
...
...
@@ -108,7 +100,7 @@ def test_create_missing_types(monkeypatch, tmp_path, mock_elements_worker, respo
],
)
worker
=
ElementsWorker
()
worker
.
configure
()
worker
.
setup_api_client
()
assert
worker
.
check_required_types
(
corpus_id
,
"
page
"
,
"
text_line
"
,
"
act
"
,
create_missing
=
True
...
...
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