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
Commits
86e16dca
Commit
86e16dca
authored
6 years ago
by
Bastien Abadie
Browse files
Options
Downloads
Patches
Plain Diff
Add test
parent
a6064b03
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!81
Api demo
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
arkindex/dataimport/tasks.py
+0
-1
0 additions, 1 deletion
arkindex/dataimport/tasks.py
arkindex/dataimport/tests/test_tasks.py
+41
-0
41 additions, 0 deletions
arkindex/dataimport/tests/test_tasks.py
arkindex/project/tests/__init__.py
+4
-0
4 additions, 0 deletions
arkindex/project/tests/__init__.py
with
45 additions
and
1 deletion
arkindex/dataimport/tasks.py
+
0
−
1
View file @
86e16dca
...
...
@@ -45,7 +45,6 @@ def check_images(self, dataimport):
fmt
=
None
try
:
print
(
datafile
.
staging_path
)
fmt
=
Image
.
open
(
datafile
.
staging_path
).
format
assert
fmt
in
(
'
JPEG
'
,
'
JPEG2000
'
)
except
IOError
as
e
:
...
...
This diff is collapsed.
Click to expand it.
arkindex/dataimport/tests/test_tasks.py
0 → 100644
+
41
−
0
View file @
86e16dca
from
arkindex.project.tests
import
RedisMockAPITestCase
from
arkindex.dataimport.tasks
import
save_classification
from
arkindex.documents.models
import
Page
,
Corpus
class
TestTasks
(
RedisMockAPITestCase
):
"""
Test data imports tasks
"""
def
test_save_classification
(
self
):
corpus
=
Corpus
.
objects
.
create
(
name
=
'
test class
'
)
dog
=
Page
.
objects
.
create
(
corpus
=
corpus
,
name
=
'
A dog
'
)
cat
=
Page
.
objects
.
create
(
corpus
=
corpus
,
name
=
'
A cat
'
)
classification
=
{
dog
.
id
:
[
{
'
label
'
:
'
dog
'
,
'
probability
'
:
0.9
,
}
],
cat
.
id
:
[
{
'
label
'
:
'
cat
'
,
'
probability
'
:
0.8
,
}
]
}
save_classification
(
classification
)
dog
.
refresh_from_db
()
self
.
assertEqual
(
dog
.
classification
,
[{
'
label
'
:
'
dog
'
,
'
probability
'
:
0.9
,
}])
cat
.
refresh_from_db
()
self
.
assertEqual
(
cat
.
classification
,
[{
'
label
'
:
'
cat
'
,
'
probability
'
:
0.8
,
}])
This diff is collapsed.
Click to expand it.
arkindex/project/tests/__init__.py
+
4
−
0
View file @
86e16dca
...
...
@@ -50,6 +50,10 @@ class RedisMockMixin(object):
for
m
in
self
.
mocked
:
m
.
return_value
=
self
.
redis
# Patch the add_message
self
.
messages
=
patch
(
'
arkindex.project.celery.ExtendedRedisBackend.add_message
'
)
self
.
messages
.
start
()
def
tearDown
(
self
):
for
p
in
self
.
patches
:
p
.
stop
()
...
...
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