Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rights Engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Polaris
Rights Engine
Commits
ca0c2635
Commit
ca0c2635
authored
2 weeks ago
by
Lennard Strohmeyer
Browse files
Options
Downloads
Patches
Plain Diff
pipeline fix
parent
ef4ae00a
No related branches found
No related tags found
1 merge request
!1
#155: fixed data disclosure tests for environments where no mongodb is...
Pipeline
#1655954
failed
2 weeks ago
Stage: test
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/data_disclosure/tests/tests_data_disclosure.py
+16
-14
16 additions, 14 deletions
src/data_disclosure/tests/tests_data_disclosure.py
with
16 additions
and
14 deletions
src/data_disclosure/tests/tests_data_disclosure.py
+
16
−
14
View file @
ca0c2635
...
...
@@ -15,7 +15,6 @@ from providers.models import ProviderAuthorization, Provider, ProviderVerbGroup,
from
users.models
import
CustomUser
from
data_disclosure.models
import
DataDisclosure
from
data_disclosure.tasks
import
DataDisclosureProcessor
...
...
@@ -38,10 +37,6 @@ class TestsDataDisclosure(BaseTestCase):
},
]
@patch.object
(
DataDisclosureProcessor
,
'
get_xapi_statements
'
)
def
mock_get_xapi_statements
(
self
,
user_email
:
str
):
return
[]
def
setUp
(
self
):
call_command
(
'
check_and_apply_migrations
'
)
normal_user
=
CustomUser
.
objects
.
create_user
(
...
...
@@ -106,16 +101,19 @@ class TestsDataDisclosure(BaseTestCase):
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_create_job
(
self
):
@patch
(
'
celery.app.task.Task.apply_async
'
)
def
test_create_job
(
self
,
celery_mock
):
self
.
assertEqual
(
DataDisclosure
.
objects
.
count
(),
0
)
response
=
self
.
user_client
.
post
(
"
/api/v1/data-disclosure/create
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
DataDisclosure
.
objects
.
count
(),
1
)
self
.
assertTrue
(
celery_mock
.
called
)
def
test_list_jobs
(
self
):
@patch
(
'
celery.app.task.Task.apply_async
'
)
def
test_list_jobs
(
self
,
celery_mock
):
response
=
self
.
user_client
.
get
(
"
/api/v1/data-disclosure/list
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
data
=
json
.
loads
(
response
.
content
.
decode
())
...
...
@@ -123,13 +121,15 @@ class TestsDataDisclosure(BaseTestCase):
response
=
self
.
user_client
.
post
(
"
/api/v1/data-disclosure/create
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
celery_mock
.
called
)
response
=
self
.
user_client
.
get
(
"
/api/v1/data-disclosure/list
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
data
=
json
.
loads
(
response
.
content
.
decode
())
self
.
assertEqual
(
len
(
data
),
1
)
def
test_get_secret
(
self
):
@patch
(
'
celery.app.task.Task.apply_async
'
)
def
test_get_secret
(
self
,
celery_mock
):
response
=
self
.
user_client
.
get
(
"
/api/v1/data-disclosure/list
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
data
=
json
.
loads
(
response
.
content
.
decode
())
...
...
@@ -137,6 +137,7 @@ class TestsDataDisclosure(BaseTestCase):
response
=
self
.
user_client
.
post
(
"
/api/v1/data-disclosure/create
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
celery_mock
.
called
)
# create second job from another account
response
=
self
.
provider_client
.
post
(
"
/api/v1/data-disclosure/create
"
)
...
...
@@ -162,8 +163,8 @@ class TestsDataDisclosure(BaseTestCase):
response
=
self
.
user_client
.
get
(
f
"
/api/v1/data-disclosure/file_secret/
{
data
[
0
][
'
id
'
]
}
"
)
# note the "user_client"
self
.
assertEqual
(
response
.
status_code
,
403
)
def
test_get_file
(
self
):
@patch
(
'
celery.app.task.Task.apply_async
'
)
def
test_get_file
(
self
,
celery_mock
):
response
=
self
.
user_client
.
get
(
"
/api/v1/data-disclosure/list
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
data
=
json
.
loads
(
response
.
content
.
decode
())
...
...
@@ -171,7 +172,7 @@ class TestsDataDisclosure(BaseTestCase):
response
=
self
.
user_client
.
post
(
"
/api/v1/data-disclosure/create
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
celery_mock
.
called
)
response
=
self
.
user_client
.
get
(
"
/api/v1/data-disclosure/list
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
@@ -206,7 +207,8 @@ class TestsDataDisclosure(BaseTestCase):
response
=
self
.
user_client
.
get
(
f
"
/api/v1/data-disclosure/files/
{
file_id
}
/
{
secret
}
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
def
test_delete_file
(
self
):
@patch
(
'
celery.app.task.Task.apply_async
'
)
def
test_delete_file
(
self
,
celery_mock
):
response
=
self
.
user_client
.
get
(
"
/api/v1/data-disclosure/list
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
data
=
json
.
loads
(
response
.
content
.
decode
())
...
...
@@ -214,7 +216,7 @@ class TestsDataDisclosure(BaseTestCase):
response
=
self
.
user_client
.
post
(
"
/api/v1/data-disclosure/create
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertTrue
(
celery_mock
.
called
)
response
=
self
.
user_client
.
get
(
"
/api/v1/data-disclosure/list
"
)
self
.
assertEqual
(
response
.
status_code
,
200
)
...
...
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