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
656492f4
Verified
Commit
656492f4
authored
11 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
test: add test for PATCH requests for schedules
parent
ddbc965e
No related branches found
No related tags found
No related merge requests found
Pipeline
#7834
passed
11 months ago
Stage: build
Stage: test
Stage: deploy
Stage: release
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/tests/test_schedules.py
+68
-1
68 additions, 1 deletion
program/tests/test_schedules.py
with
68 additions
and
1 deletion
program/tests/test_schedules.py
+
68
−
1
View file @
656492f4
from
datetime
import
datetime
,
timedelta
from
datetime
import
date
,
datetime
,
timedelta
from
typing
import
Any
from
typing
import
Any
import
pytest
import
pytest
...
@@ -216,3 +216,70 @@ def test_update_schedule(admin_api_client, once_schedule):
...
@@ -216,3 +216,70 @@ def test_update_schedule(admin_api_client, once_schedule):
assert
response
.
status_code
==
200
assert
response
.
status_code
==
200
assert_data
(
response
,
update
)
assert_data
(
response
,
update
)
def
test_patch_set_default_playlist_id
(
admin_api_client
,
once_schedule
):
update
=
{
"
default_playlist_id
"
:
42
}
response
=
admin_api_client
.
patch
(
url
(
schedule
=
once_schedule
),
data
=
update
)
assert
response
.
status_code
==
200
assert
response
.
data
[
"
default_playlist_id
"
]
==
update
[
"
default_playlist_id
"
]
def
test_patch_clear_default_playlist_id
(
admin_api_client
,
once_schedule
):
update
=
{
"
default_playlist_id
"
:
None
}
response
=
admin_api_client
.
patch
(
url
(
schedule
=
once_schedule
),
data
=
update
,
format
=
"
json
"
)
assert
response
.
status_code
==
200
assert
response
.
data
[
"
default_playlist_id
"
]
==
update
[
"
default_playlist_id
"
]
def
test_patch_set_is_repetition_true
(
admin_api_client
,
once_schedule
):
update
=
{
"
is_repetition
"
:
"
true
"
}
response
=
admin_api_client
.
patch
(
url
(
schedule
=
once_schedule
),
data
=
update
)
print
(
response
.
request
.
items
())
assert
response
.
status_code
==
200
assert
response
.
data
[
"
is_repetition
"
]
is
True
def
test_patch_set_is_repetition_false
(
admin_api_client
,
once_schedule
):
update
=
{
"
is_repetition
"
:
"
false
"
}
response
=
admin_api_client
.
patch
(
url
(
schedule
=
once_schedule
),
data
=
update
)
assert
response
.
status_code
==
200
assert
response
.
data
[
"
is_repetition
"
]
is
False
def
test_patch_last_date_delete_timeslots
(
admin_api_client
,
show_once_timeslot
):
update
=
{
"
last_date
"
:
(
date
.
today
()
-
timedelta
(
days
=
1
)).
isoformat
()}
response
=
admin_api_client
.
patch
(
url
(
schedule
=
show_once_timeslot
.
schedule
),
data
=
update
)
assert
response
.
status_code
==
200
assert
response
.
data
[
"
last_date
"
]
==
update
[
"
last_date
"
]
assert
show_once_timeslot
.
schedule
.
timeslots
.
all
().
count
()
==
0
def
test_patch_last_date
(
admin_api_client
,
show_once_timeslot
):
update
=
{
"
last_date
"
:
(
date
.
today
()
+
timedelta
(
days
=
1
)).
isoformat
()}
response
=
admin_api_client
.
patch
(
url
(
schedule
=
show_once_timeslot
.
schedule
),
data
=
update
)
assert
response
.
status_code
==
200
assert
response
.
data
[
"
last_date
"
]
==
update
[
"
last_date
"
]
assert
show_once_timeslot
.
schedule
.
timeslots
.
all
().
count
()
==
1
def
test_patch_last_date_bad_request
(
admin_api_client
,
once_schedule
):
once_schedule
.
last_date
=
date
.
today
()
+
timedelta
(
days
=
1
)
once_schedule
.
save
()
update
=
{
"
last_date
"
:
(
date
.
today
()
+
timedelta
(
days
=
2
)).
isoformat
()}
response
=
admin_api_client
.
patch
(
url
(
schedule
=
once_schedule
),
data
=
update
)
assert
response
.
status_code
==
400
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