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
028884aa
Verified
Commit
028884aa
authored
1 month ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
test: update tests for images
parent
cd950630
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/tests/test_images.py
+15
-17
15 additions, 17 deletions
program/tests/test_images.py
with
15 additions
and
17 deletions
program/tests/test_images.py
+
15
−
17
View file @
028884aa
...
...
@@ -2,7 +2,7 @@ import pytest
from
conftest
import
assert_data
from
program.models
import
Image
from
program.tests.factories
import
ContentLicens
eFactory
,
Image
Factory
from
program.tests.factories
import
Imag
eFactory
,
Licensing
Factory
pytestmark
=
pytest
.
mark
.
django_db
...
...
@@ -26,9 +26,7 @@ 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
,
content_license
=
ContentLicenseFactory
()
)
return
ImageFactory
(
image
=
image_file
,
owner
=
common_user1
,
licensing
=
LicensingFactory
())
def
test_create_image
(
image_file
,
common_api_client1
):
...
...
@@ -40,24 +38,24 @@ def test_create_image(image_file, common_api_client1):
def
test_create_image_with_license
(
image_file
,
common_api_client1
,
public_domain_license
):
content_
licens
e
=
{
licens
ing
=
{
"
credits
"
:
"
CREDITS
"
,
"
is_use_explicitly_granted_by_author
"
:
True
,
"
license_id
"
:
public_domain_license
.
id
,
}
data
=
{
"
image
"
:
image_file
}
data
.
update
({
"
content_
licens
e
.
"
+
key
:
value
for
key
,
value
in
content_
licens
e
.
items
()})
data
.
update
({
"
licens
ing
.
"
+
key
:
value
for
key
,
value
in
licens
ing
.
items
()})
response
=
common_api_client1
.
post
(
url
(),
data
=
data
)
assert
response
.
status_code
==
201
assert
response
.
data
[
"
content_
licens
e
"
][
"
credits
"
]
==
content_
licens
e
[
"
credits
"
]
assert
response
.
data
[
"
licens
ing
"
][
"
credits
"
]
==
licens
ing
[
"
credits
"
]
assert
(
response
.
data
[
"
content_
licens
e
"
][
"
is_use_explicitly_granted_by_author
"
]
is
content_
licens
e
[
"
is_use_explicitly_granted_by_author
"
]
response
.
data
[
"
licens
ing
"
][
"
is_use_explicitly_granted_by_author
"
]
is
licens
ing
[
"
is_use_explicitly_granted_by_author
"
]
)
assert
response
.
data
[
"
content_
licens
e
"
][
"
license_id
"
]
==
public_domain_license
.
id
assert
response
.
data
[
"
licens
ing
"
][
"
license_id
"
]
==
public_domain_license
.
id
def
test_delete_image
(
owned_image
,
common_api_client1
):
...
...
@@ -124,7 +122,7 @@ def test_update_alt_text_not_found_for_different_user(owned_image, common_api_cl
def
test_update_credits
(
owned_image
,
common_api_client1
,
public_domain_license
):
update
=
{
"
content_
licens
e
"
:
{
"
licens
ing
"
:
{
"
credits
"
:
"
CREDITS
"
,
},
}
...
...
@@ -133,14 +131,14 @@ def test_update_credits(owned_image, common_api_client1, public_domain_license):
assert
response
.
status_code
==
200
assert
response
.
data
[
"
content_
licens
e
"
][
"
credits
"
]
==
update
[
"
content_
licens
e
"
][
"
credits
"
]
assert
response
.
data
[
"
licens
ing
"
][
"
credits
"
]
==
update
[
"
licens
ing
"
][
"
credits
"
]
def
test_update_credits_not_found_for_different_user
(
owned_image
,
common_api_client2
,
public_domain_license
):
update
=
{
"
content_
licens
e
"
:
{
"
licens
ing
"
:
{
"
credits
"
:
"
CREDITS
"
,
}
}
...
...
@@ -170,21 +168,21 @@ 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
=
{
"
content_
licens
e
"
:
{
"
license_id
"
:
public_domain_license
.
id
},
"
licens
ing
"
:
{
"
license_id
"
:
public_domain_license
.
id
},
}
response
=
common_api_client1
.
patch
(
url
(
owned_image
),
data
=
update
,
format
=
"
json
"
)
assert
response
.
status_code
==
200
assert
response
.
data
[
"
content_
licens
e
"
][
"
license_id
"
]
==
public_domain_license
.
id
assert
response
.
data
[
"
licens
ing
"
][
"
license_id
"
]
==
public_domain_license
.
id
def
test_unset_image_license
(
owned_licensed_image
,
common_api_client1
):
update
=
{
"
content_
licens
e
"
:
None
}
update
=
{
"
licens
ing
"
:
None
}
response
=
common_api_client1
.
patch
(
url
(
owned_licensed_image
),
data
=
update
,
format
=
"
json
"
)
assert
response
.
status_code
==
200
assert
response
.
data
[
"
content_
licens
e
"
]
is
None
assert
response
.
data
[
"
licens
ing
"
]
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