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
efec17ba
Verified
Commit
efec17ba
authored
1 year ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
test: add license factory and tests for image licensing
parent
26f8dd10
No related branches found
No related tags found
No related merge requests found
Pipeline
#4690
passed
1 year ago
Stage: build
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
conftest.py
+22
-1
22 additions, 1 deletion
conftest.py
program/tests/factories.py
+10
-2
10 additions, 2 deletions
program/tests/factories.py
program/tests/test_images.py
+20
-0
20 additions, 0 deletions
program/tests/test_images.py
program/tests/test_notes.py
+3
-1
3 additions, 1 deletion
program/tests/test_notes.py
with
55 additions
and
4 deletions
conftest.py
+
22
−
1
View file @
efec17ba
...
...
@@ -5,12 +5,23 @@ from rest_framework.test import APIClient
from
django.contrib.auth.models
import
User
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
program.models
import
FundingCategory
,
Host
,
Image
,
RRule
,
Schedule
,
Show
,
TimeSlot
,
Type
from
program.models
import
(
FundingCategory
,
Host
,
Image
,
License
,
RRule
,
Schedule
,
Show
,
TimeSlot
,
Type
,
)
from
program.tests.factories
import
(
CommonUserFactory
,
FundingCategoryFactory
,
HostFactory
,
ImageFactory
,
LicenseFactory
,
RRuleFactory
,
ScheduleFactory
,
ShowFactory
,
...
...
@@ -50,6 +61,16 @@ def owned_image(image_file, common_user1) -> Image:
return
ImageFactory
(
image
=
image_file
,
owner
=
common_user1
)
@pytest.fixture
def
public_domain_license
()
->
License
:
return
LicenseFactory
()
@pytest.fixture
def
owned_licensed_image
(
image_file
,
common_user1
,
public_domain_license
)
->
Image
:
return
ImageFactory
(
image
=
image_file
,
owner
=
common_user1
,
license
=
LicenseFactory
())
@pytest.fixture
def
api_client
()
->
APIClient
:
"""
Unauthenticated API client
"""
...
...
This diff is collapsed.
Click to expand it.
program/tests/factories.py
+
10
−
2
View file @
efec17ba
from
datetime
import
time
,
timedelta
from
datetime
import
timedelta
import
factory
...
...
@@ -8,12 +8,12 @@ from program.models import (
FundingCategory
,
Host
,
Image
,
License
,
RRule
,
Schedule
,
Show
,
TimeSlot
,
Type
,
UserProfile
,
)
...
...
@@ -81,3 +81,11 @@ class TimeslotFactory(factory.django.DjangoModelFactory):
end
=
now
()
+
timedelta
(
hours
=
1
)
start
=
now
()
class
LicenseFactory
(
factory
.
django
.
DjangoModelFactory
):
class
Meta
:
model
=
License
identifier
=
"
pd
"
name
=
"
Public Domain
"
This diff is collapsed.
Click to expand it.
program/tests/test_images.py
+
20
−
0
View file @
efec17ba
...
...
@@ -122,3 +122,23 @@ def test_update_ppoi_not_found_for_different_user(owned_image, common_api_client
response
=
common_api_client2
.
patch
(
url
(
owned_image
),
data
=
update
)
assert
response
.
status_code
==
404
def
test_set_image_license
(
owned_image
,
common_api_client1
,
public_domain_license
):
update
=
{
"
license_id
"
:
public_domain_license
.
id
}
response
=
common_api_client1
.
patch
(
url
(
owned_image
),
data
=
update
)
assert
response
.
status_code
==
200
assert_data
(
response
,
update
)
def
test_unset_image_license
(
owned_licensed_image
,
common_api_client1
):
update
=
{
"
license_id
"
:
None
}
response
=
common_api_client1
.
patch
(
url
(
owned_licensed_image
),
data
=
update
,
format
=
"
json
"
)
assert
response
.
status_code
==
200
assert_data
(
response
,
update
)
This diff is collapsed.
Click to expand it.
program/tests/test_notes.py
+
3
−
1
View file @
efec17ba
from
rest_framework.test
import
APITransactionTestCase
from
unittest
import
skip
from
program
import
tests
from
program.models
import
Schedule
,
Show
...
...
@@ -71,6 +71,7 @@ class NoteViewTestCase(tests.BaseMixin, APITransactionTestCase):
)
self
.
assertEqual
(
res
.
status_code
,
201
)
@skip
(
"
nested routes are deprecated
"
)
def
test_notes_can_be_created_through_nested_routes
(
self
):
client
=
self
.
_get_client
(
self
.
user_admin
)
...
...
@@ -88,6 +89,7 @@ class NoteViewTestCase(tests.BaseMixin, APITransactionTestCase):
res
=
client
.
post
(
url
,
note
,
format
=
"
json
"
)
self
.
assertEqual
(
res
.
status_code
,
201
)
@skip
(
"
nested routes are deprecated
"
)
def
test_notes_can_be_filtered_through_nested_routes_and_query_params
(
self
):
client
=
self
.
_get_client
()
...
...
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