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
b5d1f37a
Commit
b5d1f37a
authored
8 months ago
by
Erwan Rouchet
Committed by
Valentin Rigal
8 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Clean up 5 expected failures
parent
2b58ac27
No related branches found
No related tags found
1 merge request
!2406
Clean up 5 expected failures
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/documents/tests/test_corpus_authorized_users.py
+0
-169
0 additions, 169 deletions
arkindex/documents/tests/test_corpus_authorized_users.py
arkindex/ponos/tests/test_artifacts_api.py
+13
-15
13 additions, 15 deletions
arkindex/ponos/tests/test_artifacts_api.py
with
13 additions
and
184 deletions
arkindex/documents/tests/test_corpus_authorized_users.py
deleted
100644 → 0
+
0
−
169
View file @
2b58ac27
from
unittest
import
expectedFailure
from
django.urls
import
reverse
from
rest_framework
import
status
from
arkindex.documents.models
import
Corpus
from
arkindex.project.tests
import
FixtureAPITestCase
from
arkindex.users.models
import
Role
,
User
class
TestCorpusAuthorizedUsers
(
FixtureAPITestCase
):
@classmethod
def
setUpTestData
(
cls
):
cls
.
admin
=
User
.
objects
.
create_superuser
(
"
admin@address.com
"
,
"
P4$5w0Rd
"
)
cls
.
user_one
=
User
.
objects
.
create_user
(
"
user_one@address.com
"
,
"
P4$5w0Rd
"
)
cls
.
user_two
=
User
.
objects
.
create_user
(
"
user_two@address.com
"
,
"
P4$5w0Rd
"
)
cls
.
user_three
=
User
.
objects
.
create_user
(
"
user_three@address.com
"
,
"
P4$5w0Rd
"
)
cls
.
corpus_public
=
Corpus
.
objects
.
get
(
name
=
"
Unit Tests
"
,
public
=
True
)
cls
.
corpus_private_no_rights
=
Corpus
.
objects
.
create
(
name
=
"
Private 1
"
)
cls
.
corpus_private_one_right
=
Corpus
.
objects
.
create
(
name
=
"
Private 2
"
)
cls
.
corpus_private_one_right
.
memberships
.
create
(
user
=
cls
.
user_one
,
level
=
Role
.
Guest
.
value
)
cls
.
corpus_private_n_rights
=
Corpus
.
objects
.
create
(
name
=
"
Private 3
"
)
cls
.
corpus_private_n_rights
.
memberships
.
create
(
user
=
cls
.
user_one
,
level
=
Role
.
Guest
.
value
)
cls
.
corpus_private_n_rights
.
memberships
.
create
(
user
=
cls
.
user_two
,
level
=
Role
.
Guest
.
value
)
cls
.
corpus_private_n_rights
.
memberships
.
create
(
user
=
cls
.
user_three
,
level
=
Role
.
Guest
.
value
)
def
test_admin
(
self
):
# An admin has access to everything
self
.
client
.
force_login
(
self
.
admin
)
response
=
self
.
client
.
get
(
reverse
(
"
api:corpus
"
))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
[
{
"
public
"
:
corpus
[
"
public
"
],
"
name
"
:
corpus
[
"
name
"
],
"
authorized_users
"
:
corpus
[
"
authorized_users
"
]
}
for
corpus
in
response
.
json
()
]
self
.
assertEqual
(
len
(
data
),
4
)
self
.
assertListEqual
(
data
,
[
{
"
public
"
:
False
,
"
name
"
:
"
Private 1
"
,
"
authorized_users
"
:
0
,
},
{
"
public
"
:
False
,
"
name
"
:
"
Private 2
"
,
"
authorized_users
"
:
1
,
},
{
"
public
"
:
False
,
"
name
"
:
"
Private 3
"
,
"
authorized_users
"
:
3
,
},
{
"
public
"
:
True
,
"
name
"
:
"
Unit Tests
"
,
"
authorized_users
"
:
1
,
}
]
)
@expectedFailure
def
test_user_one
(
self
):
self
.
client
.
force_login
(
self
.
user_one
)
response
=
self
.
client
.
get
(
reverse
(
"
api:corpus
"
))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
[
{
"
public
"
:
corpus
[
"
public
"
],
"
name
"
:
corpus
[
"
name
"
],
"
authorized_users
"
:
corpus
[
"
authorized_users
"
]
}
for
corpus
in
response
.
json
()
]
self
.
assertEqual
(
len
(
data
),
3
)
self
.
assertListEqual
(
data
,
[
{
"
public
"
:
False
,
"
name
"
:
"
Private 2
"
,
"
authorized_users
"
:
1
,
},
{
"
public
"
:
False
,
"
name
"
:
"
Private 3
"
,
"
authorized_users
"
:
3
,
},
{
"
public
"
:
True
,
"
name
"
:
"
Unit Tests
"
,
"
authorized_users
"
:
1
,
}
]
)
@expectedFailure
def
test_user_two
(
self
):
self
.
client
.
force_login
(
self
.
user_two
)
response
=
self
.
client
.
get
(
reverse
(
"
api:corpus
"
))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
[
{
"
public
"
:
corpus
[
"
public
"
],
"
name
"
:
corpus
[
"
name
"
],
"
authorized_users
"
:
corpus
[
"
authorized_users
"
]
}
for
corpus
in
response
.
json
()
]
self
.
assertEqual
(
len
(
data
),
2
)
self
.
assertListEqual
(
data
,
[
{
"
public
"
:
False
,
"
name
"
:
"
Private 3
"
,
"
authorized_users
"
:
3
,
},
{
"
public
"
:
True
,
"
name
"
:
"
Unit Tests
"
,
"
authorized_users
"
:
1
,
}
]
)
@expectedFailure
def
test_user_three
(
self
):
self
.
client
.
force_login
(
self
.
user_three
)
response
=
self
.
client
.
get
(
reverse
(
"
api:corpus
"
))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
[
{
"
public
"
:
corpus
[
"
public
"
],
"
name
"
:
corpus
[
"
name
"
],
"
authorized_users
"
:
corpus
[
"
authorized_users
"
]
}
for
corpus
in
response
.
json
()
]
self
.
assertEqual
(
len
(
data
),
2
)
self
.
assertListEqual
(
data
,
[
{
"
public
"
:
False
,
"
name
"
:
"
Private 3
"
,
"
authorized_users
"
:
3
,
},
{
"
public
"
:
True
,
"
name
"
:
"
Unit Tests
"
,
"
authorized_users
"
:
1
,
}
]
)
This diff is collapsed.
Click to expand it.
arkindex/ponos/tests/test_artifacts_api.py
+
13
−
15
View file @
b5d1f37a
from
unittest
import
expectedFailure
from
unittest
.mock
import
call
,
patch
from
django.conf
import
settings
from
django.test
import
override_settings
...
...
@@ -61,19 +61,17 @@ class TestAPI(FixtureAPITestCase):
response
=
self
.
client
.
get
(
reverse
(
"
api:task-artifacts
"
,
args
=
[
self
.
task1
.
id
]))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
@expectedFailure
def
test_list_requires_process_guest
(
self
):
self
.
process
.
creator
=
self
.
superuser
self
.
process
.
save
()
self
.
corpus
.
memberships
.
filter
(
user
=
self
.
user
).
delete
()
self
.
corpus
.
public
=
False
self
.
corpus
.
save
()
@patch
(
"
arkindex.project.mixins.get_max_level
"
,
return_value
=
None
)
def
test_list_requires_process_guest
(
self
,
get_max_level_mock
):
self
.
client
.
force_login
(
self
.
user
)
with
self
.
assertNumQueries
(
5
):
with
self
.
assertNumQueries
(
3
):
response
=
self
.
client
.
get
(
reverse
(
"
api:task-artifacts
"
,
args
=
[
self
.
task1
.
id
]))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
self
.
assertEqual
(
get_max_level_mock
.
call_count
,
1
)
self
.
assertEqual
(
get_max_level_mock
.
call_args
,
call
(
self
.
user
,
self
.
corpus
))
def
test_list_process_level_corpus
(
self
):
self
.
process
.
creator
=
self
.
superuser
self
.
process
.
save
()
...
...
@@ -345,19 +343,19 @@ class TestAPI(FixtureAPITestCase):
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
@expectedFailure
def
test_download_requires_process_guest
(
self
):
self
.
corpus
.
memberships
.
filter
(
user
=
self
.
user
).
delete
()
self
.
corpus
.
public
=
False
self
.
corpus
.
save
()
@patch
(
"
arkindex.project.mixins.get_max_level
"
,
return_value
=
None
)
def
test_download_requires_process_guest
(
self
,
get_max_level_mock
):
self
.
client
.
force_login
(
self
.
user
)
with
self
.
assertNumQueries
(
5
):
with
self
.
assertNumQueries
(
3
):
response
=
self
.
client
.
get
(
reverse
(
"
api:task-artifact-download
"
,
args
=
[
self
.
task1
.
id
,
"
path/to/file.json
"
]),
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_403_FORBIDDEN
)
self
.
assertEqual
(
get_max_level_mock
.
call_count
,
1
)
self
.
assertEqual
(
get_max_level_mock
.
call_args
,
call
(
self
.
user
,
self
.
corpus
))
def
test_download_process_level_corpus
(
self
):
self
.
client
.
force_login
(
self
.
user
)
...
...
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