*** Settings *** Documentation Configuration API tests for Aniworld. ... Covers get, update, validate, backup create/list/restore/delete, and export/import. 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 Default Config [Documentation] Retrieve the current configuration and verify its structure. ${resp}= GET API /api/config Response Should Have Status ${resp} 200 Response Should Contain Keys ${resp} name data_dir scheduler logging backup nfo Update Config [Documentation] Update configuration fields and verify they are persisted. ${payload}= Create Dictionary ... name=UpdatedAniworld ... data_dir=data ... scheduler={'enabled': False, 'schedule_time': '04:00', 'schedule_days': ['mon', 'tue']} ... logging={'level': 'DEBUG', 'file': 'logs/test.log', 'max_bytes': 1048576, 'backup_count': 5} ... backup={'enabled': False} ... nfo={'tmdb_api_key': '', 'auto_create': False, 'download_poster': False, 'download_logo': False, 'download_fanart': False} ... other={'anime_directory': '/tmp/aniworld_test_anime'} ${resp}= Update Config ${payload} Response Should Have Status ${resp} 200 ${config}= Get Current Config Should Be Equal As Strings ${config}[name] UpdatedAniworld # --------------------------------------------------------------------------- # Config Validation # --------------------------------------------------------------------------- Validate Valid Config [Documentation] Validate a well-formed configuration. ${schedule_days}= Create List mon tue wed thu fri sat sun ${payload}= Evaluate json.loads('''{"name": "Aniworld", "data_dir": "data", "scheduler": {"enabled": true, "schedule_time": "03:00", "schedule_days": ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]}, "logging": {"level": "INFO", "backup_count": 3}, "backup": {"enabled": false}, "nfo": {"tmdb_api_key": "", "auto_create": true, "download_poster": true, "download_logo": true, "download_fanart": true}, "other": {}}''') modules=json ${resp}= Validate Config ${payload} 200 Response Should Have Status ${resp} 200 ${valid}= Get JSON Value ${resp} $.valid Should Be Equal As Strings ${valid} True Validate Invalid Config Missing Name [Documentation] Validate a config missing the required 'name' field. ${payload}= Create Dictionary ... data_dir=data ... scheduler={'enabled': True, 'schedule_time': '03:00', 'schedule_days': ['mon']} ... logging={'level': 'INFO'} ... backup={'enabled': False} ... nfo={'auto_create': False} ... other={} ${resp}= Validate Config ${payload} 422 Response Should Have Status ${resp} 422 Validate Invalid Schedule Time [Documentation] Validate a config with malformed schedule_time. ${payload}= Create Dictionary ... name=Aniworld ... data_dir=data ... scheduler={'enabled': True, 'schedule_time': '25:00', 'schedule_days': ['mon']} ... logging={'level': 'INFO'} ... backup={'enabled': False} ... nfo={'auto_create': False} ... other={} ${resp}= Validate Config ${payload} 422 Response Should Have Status ${resp} 422 Validate Invalid Log Level [Documentation] Validate a config with an invalid logging level. ${payload}= Evaluate json.loads('''{"name": "Aniworld", "data_dir": "data", "scheduler": {"enabled": true, "schedule_time": "03:00", "schedule_days": ["mon"]}, "logging": {"level": "INVALID", "backup_count": 3}, "backup": {"enabled": false}, "nfo": {"auto_create": false}, "other": {}}''') modules=json ${resp}= Validate Config ${payload} 422 Response Should Have Status ${resp} 422 # --------------------------------------------------------------------------- # Backup Management # --------------------------------------------------------------------------- Config Backup Create [Documentation] Create a configuration backup and verify it exists. ${resp}= POST API /api/config/backups expected_status=201 Response Should Have Status ${resp} 201 Config Backup List [Documentation] List configuration backups and verify the response structure. POST API /api/config/backups expected_status=201 ${resp}= GET API /api/config/backups Response Should Have Status ${resp} 200 Response Should Contain Key ${resp} $.backups Config Backup Restore [Documentation] Create a backup, change config, then restore and verify reversion. ${resp}= POST API /api/config/backups expected_status=201 ${json}= Convert String To Json ${resp.text} ${backup_name}= Get Value From Json ${json} $.name ${name_before}= Set Variable ${backup_name}[0] # Change config ${scheduler}= Evaluate {'enabled': False, 'schedule_time': '03:00', 'schedule_days': ['mon']} ${logging}= Evaluate {'level': 'INFO', 'file': None, 'max_bytes': None, 'backup_count': 3} ${backup}= Evaluate {'enabled': False} ${nfo}= Evaluate {'auto_create': False} ${other}= Evaluate {} ${payload}= Create Dictionary ... name=BeforeRestore ... data_dir=data ... scheduler=${scheduler} ... logging=${logging} ... backup=${backup} ... nfo=${nfo} ... other=${other} Update Config ${payload} # Restore ${resp}= POST API /api/config/backups/${name_before}/restore Response Should Have Status ${resp} 200 Config Backup Delete [Documentation] Create a backup and then delete it. ${resp}= POST API /api/config/backups expected_status=201 ${json}= Convert String To Json ${resp.text} ${backup_name}= Get Value From Json ${json} $.name ${name}= Set Variable ${backup_name}[0] ${del_resp}= DELETE API /api/config/backups/${name} Response Should Have Status ${del_resp} 200