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
b3b47bbf
Verified
Commit
b3b47bbf
authored
9 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
test: add test that update links in hosts & notes
parent
edd0079b
No related branches found
No related tags found
No related merge requests found
Pipeline
#8283
passed
9 months ago
Stage: check
Stage: test
Stage: build
Stage: deploy
Stage: release
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
program/tests/test_hosts.py
+15
-1
15 additions, 1 deletion
program/tests/test_hosts.py
program/tests/test_notes.py
+32
-3
32 additions, 3 deletions
program/tests/test_notes.py
with
47 additions
and
4 deletions
program/tests/test_hosts.py
+
15
−
1
View file @
b3b47bbf
import
pytest
from
conftest
import
assert_data
from
program.models
import
LinkType
from
program.tests.factories
import
HostFactory
pytestmark
=
pytest
.
mark
.
django_db
...
...
@@ -10,7 +11,7 @@ def url(host=None) -> str:
return
f
"
/api/v1/hosts/
{
host
.
id
}
/
"
if
host
else
"
/api/v1/hosts/
"
def
host_data
(
image
=
None
)
->
dict
[
str
,
str
|
int
]:
def
host_data
(
image
=
None
,
link_type
:
LinkType
=
None
)
->
dict
[
str
,
str
|
int
]:
data
=
{
"
biography
"
:
"
BIOGRAPHY
"
,
"
email
"
:
"
host@aura.radio
"
,
...
...
@@ -20,6 +21,9 @@ def host_data(image=None) -> dict[str, str | int]:
if
image
:
data
[
"
image_id
"
]
=
image
.
id
if
link_type
:
data
[
"
links
"
]
=
[{
"
type_id
"
:
link_type
.
id
,
"
url
"
:
"
https://aura.radio
"
}]
return
data
...
...
@@ -79,6 +83,16 @@ def test_update_host(admin_api_client, host, image):
assert_data
(
response
,
update
)
def
test_update_host_links
(
admin_api_client
,
host
,
link_type
):
update
=
host_data
(
link_type
=
link_type
)
response
=
admin_api_client
.
patch
(
url
(
host
),
data
=
update
,
format
=
"
json
"
)
assert
response
.
status_code
==
200
assert_data
(
response
,
update
)
def
test_update_host_forbidden_for_common_user
(
common_api_client1
,
host
):
update
=
host_data
()
...
...
This diff is collapsed.
Click to expand it.
program/tests/test_notes.py
+
32
−
3
View file @
b3b47bbf
import
pytest
from
program.models
import
Note
,
TimeSlot
from
conftest
import
assert_data
from
program.models
import
LinkType
,
Note
,
TimeSlot
from
program.tests.factories
import
NoteFactory
pytestmark
=
pytest
.
mark
.
django_db
...
...
@@ -13,8 +14,17 @@ def url(note=None):
return
"
/api/v1/notes/
"
def
note_data
(
timeslot
:
TimeSlot
)
->
dict
[
str
,
str
|
int
]:
return
{
"
content
"
:
"
CONTENT
"
,
"
title
"
:
"
TITLE
"
,
"
timeslot_id
"
:
timeslot
.
id
}
def
note_data
(
timeslot
:
TimeSlot
,
link_type
:
LinkType
=
None
)
->
dict
[
str
,
str
|
int
]:
data
=
{
"
content
"
:
"
CONTENT
"
,
"
title
"
:
"
TITLE
"
,
"
timeslot_id
"
:
timeslot
.
id
,
}
if
link_type
:
data
[
"
links
"
]
=
[{
"
type_id
"
:
link_type
.
id
,
"
url
"
:
"
https://aura.radio
"
}]
return
data
def
test_read_notes_as_unauthenticated_user
(
api_client
):
...
...
@@ -71,6 +81,8 @@ def test_update_note_for_owned_show(
assert
response
.
status_code
==
200
assert_data
(
response
,
update
)
def
test_update_note_not_found_for_not_owned_show
(
user_with_note_perms
,
api_client_note_perms
,
once_timeslot
...
...
@@ -82,6 +94,23 @@ def test_update_note_not_found_for_not_owned_show(
assert
response
.
status_code
==
404
def
test_update_note_links
(
user_with_note_perms
,
api_client_note_perms
,
owned_show_once_timeslot_perms
,
link_type
,
):
update
=
note_data
(
timeslot
=
owned_show_once_timeslot_perms
,
link_type
=
link_type
)
response
=
api_client_note_perms
.
patch
(
url
(
note
=
owned_show_once_timeslot_perms
.
note
),
data
=
update
,
format
=
"
json
"
)
assert
response
.
status_code
==
200
assert_data
(
response
,
update
)
def
test_delete_note_for_owned_show
(
user_with_note_perms
,
api_client_note_perms
,
owned_show_once_timeslot_perms
):
...
...
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