Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
AURA
steering
Commits
53766dd1
Verified
Commit
53766dd1
authored
3 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
test: fix image tests
parent
c480aba7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/tests/test_images.py
+29
-15
29 additions, 15 deletions
program/tests/test_images.py
with
29 additions
and
15 deletions
program/tests/test_images.py
+
29
−
15
View file @
53766dd1
...
...
@@ -2,7 +2,7 @@ import pytest
from
conftest
import
assert_data
from
program.models
import
Image
from
program.tests.factories
import
Imag
eFactory
,
Licens
eFactory
from
program.tests.factories
import
ContentLicens
eFactory
,
Imag
eFactory
pytestmark
=
pytest
.
mark
.
django_db
...
...
@@ -26,7 +26,9 @@ def owned_image(image_file, common_user1) -> Image:
@pytest.fixture
def
owned_licensed_image
(
image_file
,
common_user1
,
public_domain_license
)
->
Image
:
return
ImageFactory
(
image
=
image_file
,
owner
=
common_user1
,
license
=
LicenseFactory
())
return
ImageFactory
(
image
=
image_file
,
owner
=
common_user1
,
content_license
=
ContentLicenseFactory
()
)
def
test_create_image
(
image_file
,
common_api_client1
):
...
...
@@ -92,27 +94,37 @@ def test_update_alt_text(owned_image, common_api_client1):
def
test_update_alt_text_not_found_for_different_user
(
owned_image
,
common_api_client2
):
update
=
{
"
alt_text
"
:
"
ALT_TEXT
"
,
"
credits
"
:
"
CREDITS
"
}
update
=
{
"
alt_text
"
:
"
ALT_TEXT
"
}
response
=
common_api_client2
.
patch
(
url
(
owned_image
),
data
=
update
)
assert
response
.
status_code
==
404
def
test_update_credits
(
owned_image
,
common_api_client1
):
update
=
{
"
credits
"
:
"
CREDITS
"
}
def
test_update_credits
(
owned_image
,
common_api_client1
,
public_domain_license
):
update
=
{
"
content_license
"
:
{
"
credits
"
:
"
CREDITS
"
,
},
}
response
=
common_api_client1
.
patch
(
url
(
owned_image
),
data
=
update
)
response
=
common_api_client1
.
patch
(
url
(
owned_image
),
data
=
update
,
format
=
"
json
"
)
assert
response
.
status_code
==
200
assert
_data
(
response
,
update
)
assert
response
.
data
[
"
content_license
"
][
"
credits
"
]
==
update
[
"
content_license
"
][
"
credits
"
]
def
test_update_credits_not_found_for_different_user
(
owned_image
,
common_api_client2
):
update
=
{
"
credits
"
:
"
CREDITS
"
}
def
test_update_credits_not_found_for_different_user
(
owned_image
,
common_api_client2
,
public_domain_license
):
update
=
{
"
content_license
"
:
{
"
credits
"
:
"
CREDITS
"
,
}
}
response
=
common_api_client2
.
patch
(
url
(
owned_image
),
data
=
update
)
response
=
common_api_client2
.
patch
(
url
(
owned_image
),
data
=
update
,
format
=
"
json
"
)
assert
response
.
status_code
==
404
...
...
@@ -136,20 +148,22 @@ def test_update_ppoi_not_found_for_different_user(owned_image, common_api_client
def
test_set_image_license
(
owned_image
,
common_api_client1
,
public_domain_license
):
update
=
{
"
license_id
"
:
public_domain_license
.
id
}
update
=
{
"
content_license
"
:
{
"
license_id
"
:
public_domain_license
.
id
},
}
response
=
common_api_client1
.
patch
(
url
(
owned_image
),
data
=
update
)
response
=
common_api_client1
.
patch
(
url
(
owned_image
),
data
=
update
,
format
=
"
json
"
)
assert
response
.
status_code
==
200
assert
_data
(
response
,
update
)
assert
response
.
data
[
"
content_license
"
][
"
license_id
"
]
==
public_domain_license
.
id
def
test_unset_image_license
(
owned_licensed_image
,
common_api_client1
):
update
=
{
"
license
_id
"
:
None
}
update
=
{
"
content_
license
"
:
None
}
response
=
common_api_client1
.
patch
(
url
(
owned_licensed_image
),
data
=
update
,
format
=
"
json
"
)
assert
response
.
status_code
==
200
assert
_data
(
response
,
update
)
assert
response
.
data
[
"
content_license
"
]
is
None
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