# Path: slicer_cli_web/config.py
# class PluginSettings:
#     SLICER_CLI_WEB_TASK_FOLDER = 'slicer_cli_web.task_folder'
# 
#     @staticmethod
#     def has_task_folder():
#         return Setting().get(PluginSettings.SLICER_CLI_WEB_TASK_FOLDER) is not None
# 
#     @staticmethod
#     def get_task_folder():
#         folder = Setting().get(PluginSettings.SLICER_CLI_WEB_TASK_FOLDER)
#         if not folder:
#             return None
#         return Folder().load(folder, level=AccessType.READ, user=getCurrentUser())


import pytest
from pytest_girder.assertions import assertStatusOk, assertStatus
from slicer_cli_web.config import PluginSettings



@pytest.mark.plugin('slicer_cli_web')
def test_default_task_folder(server, admin, folder):
    # Test the setting
    resp = server.request('/system/setting', method='PUT', params={
        'key': PluginSettings.SLICER_CLI_WEB_TASK_FOLDER,
        'value': 'bad value'
    }, user=admin)
    assertStatus(resp, 400)
    resp = server.request('/system/setting', method='PUT', params={
        'key': PluginSettings.SLICER_CLI_WEB_TASK_FOLDER,
        'value': folder['_id']
    }, user=admin)
    assertStatusOk(resp)

    assert PluginSettings.has_task_folder()

# Path: slicer_cli_web/config.py
# class PluginSettings:
#     SLICER_CLI_WEB_TASK_FOLDER = 'slicer_cli_web.task_folder'
# 
#     @staticmethod
#     def has_task_folder():
#         return Setting().get(PluginSettings.SLICER_CLI_WEB_TASK_FOLDER) is not None
# 
#     @staticmethod
#     def get_task_folder():
#         folder = Setting().get(PluginSettings.SLICER_CLI_WEB_TASK_FOLDER)
#         if not folder:
#             return None
#         return Folder().load(folder, level=AccessType.READ, user=getCurrentUser())


# Path: tests/test_config.py
import pytest
from pytest_girder.assertions import assertStatusOk, assertStatus
from slicer_cli_web.config import PluginSettings




@pytest.mark.plugin('slicer_cli_web')
def test_default_task_folder(server, admin, folder):
    # Test the setting
    resp = server.request('/system/setting', method='PUT', params={
        'key': PluginSettings.SLICER_CLI_WEB_TASK_FOLDER,
        'value': 'bad value'
    }, user=admin)
    assertStatus(resp, 400)
    resp = server.request('/system/setting', method='PUT', params={
        'key': PluginSettings.SLICER_CLI_WEB_TASK_FOLDER,
        'value': folder['_id']
    }, user=admin)
    assertStatusOk(resp)

    assert PluginSettings.has_task_folder()

    assert PluginSettings.get_task_folder()['_id'] == folder['_id']