Robot Framework's Create Dictionary converts ['mon', 'tue'] into a string. Add _parse_schedule_days to handle JSON/Python-literal parsing before Pydantic type validation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
86 lines
3.8 KiB
Plaintext
86 lines
3.8 KiB
Plaintext
*** Settings ***
|
|
Documentation Scheduler API tests for Aniworld.
|
|
... Covers get config, update config, trigger rescan, and validation.
|
|
|
|
Resource ${CURDIR}/../resources/common.resource
|
|
Resource ${CURDIR}/../resources/api_keywords.resource
|
|
|
|
Test Setup Run Keywords
|
|
... Create Anonymous Session
|
|
... AND Setup Master Password
|
|
... AND Create Authenticated Session
|
|
|
|
Test Teardown Delete All Sessions
|
|
|
|
*** Test Cases ***
|
|
# ---------------------------------------------------------------------------
|
|
# Get / Update Config
|
|
# ---------------------------------------------------------------------------
|
|
Get Scheduler Config
|
|
[Documentation] Retrieve the current scheduler configuration and runtime status.
|
|
${resp}= Get Scheduler Config
|
|
Response Should Have Status ${resp} 200
|
|
Response Should Contain Keys ${resp} success config status
|
|
${config_keys}= Create List enabled interval_minutes schedule_time schedule_days auto_download_after_rescan
|
|
FOR ${key} IN @{config_keys}
|
|
Response Should Contain Key ${resp} $.config.${key}
|
|
END
|
|
${status_keys}= Create List is_running next_run last_run scan_in_progress
|
|
FOR ${key} IN @{status_keys}
|
|
Response Should Contain Key ${resp} $.status.${key}
|
|
END
|
|
|
|
Update Scheduler Config
|
|
[Documentation] Update scheduler settings and verify they are persisted.
|
|
${payload}= Evaluate json.loads('''{"enabled": true, "interval_minutes": 120, "schedule_time": "04:30", "schedule_days": ["mon", "wed", "fri"], "auto_download_after_rescan": true}''') modules=json
|
|
${resp}= Update Scheduler Config ${payload}
|
|
Response Should Have Status ${resp} 200
|
|
${saved_time}= Get JSON Value ${resp} $.config.schedule_time
|
|
Should Be Equal As Strings ${saved_time} 04:30
|
|
${saved_days}= Get JSON Value ${resp} $.config.schedule_days
|
|
List Should Contain Value ${saved_days} mon
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Trigger Rescan
|
|
# ---------------------------------------------------------------------------
|
|
Trigger Manual Rescan
|
|
[Documentation] Manually trigger a scheduled rescan.
|
|
${resp}= Trigger Rescan
|
|
Response Should Have Status ${resp} 200
|
|
${success}= Get JSON Value ${resp} $.success
|
|
Should Be Equal As Strings ${success} True
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Validation
|
|
# ---------------------------------------------------------------------------
|
|
Invalid Schedule Time
|
|
[Documentation] Verify that malformed schedule_time is rejected.
|
|
${payload}= Create Dictionary
|
|
... enabled=True
|
|
... interval_minutes=60
|
|
... schedule_time=25:00
|
|
... schedule_days=['mon']
|
|
... auto_download_after_rescan=False
|
|
${resp}= POST API /api/scheduler/config ${payload} expected_status=422
|
|
|
|
Invalid Schedule Days
|
|
[Documentation] Verify that invalid day abbreviations are rejected.
|
|
${payload}= Create Dictionary
|
|
... enabled=True
|
|
... interval_minutes=60
|
|
... schedule_time=03:00
|
|
... schedule_days=['monday', 'tuesday']
|
|
... auto_download_after_rescan=False
|
|
${resp}= POST API /api/scheduler/config ${payload} expected_status=422
|
|
|
|
Empty Schedule Days
|
|
[Documentation] Verify that empty schedule_days is handled.
|
|
${payload}= Create Dictionary
|
|
... enabled=True
|
|
... interval_minutes=60
|
|
... schedule_time=03:00
|
|
... schedule_days=[]
|
|
... auto_download_after_rescan=False
|
|
${resp}= Update Scheduler Config ${payload}
|
|
Response Should Have Status ${resp} 200
|