"""Unit tests of authorization searches."""


import pytest


from ..utilities.general import is_never_authz, is_no_authz, uses_cataloging, uses_filesystem_only
from dlkit.abstract_osid.osid import errors
from dlkit.primordium.id.primitives import Id
from dlkit.primordium.type.primitives import Type
from dlkit.runtime import PROXY_SESSION, proxy_example
from dlkit.runtime.managers import Runtime


REQUEST = proxy_example.SimpleRequest()
CONDITION = PROXY_SESSION.get_proxy_condition()
CONDITION.set_http_request(REQUEST)
PROXY = PROXY_SESSION.get_proxy(CONDITION)

DEFAULT_TYPE = Type(**{'identifier': 'DEFAULT', 'namespace': 'DEFAULT', 'authority': 'DEFAULT'})


@pytest.fixture(scope="class",
                params=['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ', 'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM', 'TEST_SERVICE_MEMCACHE'])
def authorization_search_class_fixture(request):
    # From test_templates/resource.py::ResourceSearch::init_template
    request.cls.service_config = request.param
    request.cls.svc_mgr = Runtime().get_service_manager(
        'AUTHORIZATION',
        proxy=PROXY,
        implementation=request.cls.service_config)
    create_form = request.cls.svc_mgr.get_vault_form_for_create([])
    create_form.display_name = 'Test catalog'
    create_form.description = 'Test catalog description'
    request.cls.catalog = request.cls.svc_mgr.create_vault(create_form)

    def class_tear_down():
        request.cls.svc_mgr.delete_vault(request.cls.catalog.ident)

    request.addfinalizer(class_tear_down)


@pytest.fixture(scope="function")
def authorization_search_test_fixture(request):
    # From test_templates/resource.py::ResourceSearch::init_template
    request.cls.search = request.cls.catalog.get_authorization_search()


@pytest.mark.usefixtures("authorization_search_class_fixture", "authorization_search_test_fixture")
class TestAuthorizationSearch(object):
    """Tests for AuthorizationSearch"""
    @pytest.mark.skip('unimplemented test')
    def test_search_among_authorizations(self):
        """Tests search_among_authorizations"""
        pass

    @pytest.mark.skip('unimplemented test')
    def test_order_authorization_results(self):
        """Tests order_authorization_results"""
        pass

    @pytest.mark.skip('unimplemented test')
    def test_get_authorization_search_record(self):
        """Tests get_authorization_search_record"""
        pass


@pytest.mark.usefixtures("authorization_search_results_class_fixture", "authorization_search_results_test_fixture")
class TestAuthorizationSearchResults(object):
    """Tests for AuthorizationSearchResults"""
    @pytest.mark.skip('unimplemented test')
    def test_get_authorizations(self):
        """Tests get_authorizations"""
        pass

    @pytest.mark.skip('unimplemented test')
    def test_get_authorization_query_inspector(self):
        """Tests get_authorization_query_inspector"""
        pass

    @pytest.mark.skip('unimplemented test')
    def test_get_authorization_search_results_record(self):
        """Tests get_authorization_search_results_record"""
        pass


@pytest.fixture(scope="class",
                params=['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ', 'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM', 'TEST_SERVICE_MEMCACHE'])
def vault_search_class_fixture(request):
    # From test_templates/resource.py::ResourceSearch::init_template
    request.cls.service_config = request.param
    request.cls.svc_mgr = Runtime().get_service_manager(
        'AUTHORIZATION',
        proxy=PROXY,
        implementation=request.cls.service_config)
    create_form = request.cls.svc_mgr.get_vault_form_for_create([])
    create_form.display_name = 'Test catalog'
    create_form.description = 'Test catalog description'
    request.cls.catalog = request.cls.svc_mgr.create_vault(create_form)

    def class_tear_down():
        request.cls.svc_mgr.delete_vault(request.cls.catalog.ident)

    request.addfinalizer(class_tear_down)


@pytest.fixture(scope="function")
def vault_search_test_fixture(request):
    # From test_templates/resource.py::ResourceSearch::init_template
    request.cls.search = request.cls.catalog.get_vault_search()


@pytest.mark.usefixtures("vault_search_class_fixture", "vault_search_test_fixture")
class TestVaultSearch(object):
    """Tests for VaultSearch"""
    @pytest.mark.skip('unimplemented test')
    def test_search_among_vaults(self):
        """Tests search_among_vaults"""
        pass

    @pytest.mark.skip('unimplemented test')
    def test_order_vault_results(self):
        """Tests order_vault_results"""
        pass

    @pytest.mark.skip('unimplemented test')
    def test_get_vault_search_record(self):
        """Tests get_vault_search_record"""
        pass


@pytest.mark.usefixtures("vault_search_results_class_fixture", "vault_search_results_test_fixture")
class TestVaultSearchResults(object):
    """Tests for VaultSearchResults"""
    @pytest.mark.skip('unimplemented test')
    def test_get_vaults(self):
        """Tests get_vaults"""
        pass

    @pytest.mark.skip('unimplemented test')
    def test_get_vault_query_inspector(self):
        """Tests get_vault_query_inspector"""
        pass

    @pytest.mark.skip('unimplemented test')
    def test_get_vault_search_results_record(self):
        """Tests get_vault_search_results_record"""
        pass

[((411, 440), 'dlkit.runtime.proxy_example.SimpleRequest', 'proxy_example.SimpleRequest', ([], {}), '()\n', (438, 440), False, 'from dlkit.runtime import PROXY_SESSION, proxy_example\n'), ((453, 488), 'dlkit.runtime.PROXY_SESSION.get_proxy_condition', 'PROXY_SESSION.get_proxy_condition', ([], {}), '()\n', (486, 488), False, 'from dlkit.runtime import PROXY_SESSION, proxy_example\n'), ((533, 567), 'dlkit.runtime.PROXY_SESSION.get_proxy', 'PROXY_SESSION.get_proxy', (['CONDITION'], {}), '(CONDITION)\n', (556, 567), False, 'from dlkit.runtime import PROXY_SESSION, proxy_example\n'), ((584, 669), 'dlkit.primordium.type.primitives.Type', 'Type', ([], {}), "(**{'identifier': 'DEFAULT', 'namespace': 'DEFAULT', 'authority':\n    'DEFAULT'})\n", (588, 669), False, 'from dlkit.primordium.type.primitives import Type\n'), ((669, 871), 'pytest.fixture', 'pytest.fixture', ([], {'scope': '"""class"""', 'params': "['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ',\n    'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM',\n    'TEST_SERVICE_MEMCACHE']"}), "(scope='class', params=['TEST_SERVICE',\n    'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ',\n    'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM',\n    'TEST_SERVICE_MEMCACHE'])\n", (683, 871), False, 'import pytest\n'), ((1580, 1612), 'pytest.fixture', 'pytest.fixture', ([], {'scope': '"""function"""'}), "(scope='function')\n", (1594, 1612), False, 'import pytest\n'), ((1805, 1907), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', (['"""authorization_search_class_fixture"""', '"""authorization_search_test_fixture"""'], {}), "('authorization_search_class_fixture',\n    'authorization_search_test_fixture')\n", (1828, 1907), False, 'import pytest\n'), ((2455, 2573), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', (['"""authorization_search_results_class_fixture"""', '"""authorization_search_results_test_fixture"""'], {}), "('authorization_search_results_class_fixture',\n    'authorization_search_results_test_fixture')\n", (2478, 2573), False, 'import pytest\n'), ((3145, 3347), 'pytest.fixture', 'pytest.fixture', ([], {'scope': '"""class"""', 'params': "['TEST_SERVICE', 'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ',\n    'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM',\n    'TEST_SERVICE_MEMCACHE']"}), "(scope='class', params=['TEST_SERVICE',\n    'TEST_SERVICE_ALWAYS_AUTHZ', 'TEST_SERVICE_NEVER_AUTHZ',\n    'TEST_SERVICE_CATALOGING', 'TEST_SERVICE_FILESYSTEM',\n    'TEST_SERVICE_MEMCACHE'])\n", (3159, 3347), False, 'import pytest\n'), ((4048, 4080), 'pytest.fixture', 'pytest.fixture', ([], {'scope': '"""function"""'}), "(scope='function')\n", (4062, 4080), False, 'import pytest\n'), ((4257, 4343), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', (['"""vault_search_class_fixture"""', '"""vault_search_test_fixture"""'], {}), "('vault_search_class_fixture',\n    'vault_search_test_fixture')\n", (4280, 4343), False, 'import pytest\n'), ((4827, 4929), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', (['"""vault_search_results_class_fixture"""', '"""vault_search_results_test_fixture"""'], {}), "('vault_search_results_class_fixture',\n    'vault_search_results_test_fixture')\n", (4850, 4929), False, 'import pytest\n'), ((1988, 2026), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (2004, 2026), False, 'import pytest\n'), ((2142, 2180), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (2158, 2180), False, 'import pytest\n'), ((2296, 2334), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (2312, 2334), False, 'import pytest\n'), ((2668, 2706), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (2684, 2706), False, 'import pytest\n'), ((2804, 2842), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (2820, 2842), False, 'import pytest\n'), ((2970, 3008), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (2986, 3008), False, 'import pytest\n'), ((4408, 4446), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (4424, 4446), False, 'import pytest\n'), ((4546, 4584), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (4562, 4584), False, 'import pytest\n'), ((4684, 4722), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (4700, 4722), False, 'import pytest\n'), ((5008, 5046), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (5024, 5046), False, 'import pytest\n'), ((5128, 5166), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (5144, 5166), False, 'import pytest\n'), ((5278, 5316), 'pytest.mark.skip', 'pytest.mark.skip', (['"""unimplemented test"""'], {}), "('unimplemented test')\n", (5294, 5316), False, 'import pytest\n'), ((1067, 1076), 'dlkit.runtime.managers.Runtime', 'Runtime', ([], {}), '()\n', (1074, 1076), False, 'from dlkit.runtime.managers import Runtime\n'), ((3535, 3544), 'dlkit.runtime.managers.Runtime', 'Runtime', ([], {}), '()\n', (3542, 3544), False, 'from dlkit.runtime.managers import Runtime\n')]