# Path: freezer_api/context.py
# LOG = log.getLogger(__name__)
# class FreezerContext(context.RequestContext):
#     def __init__(self, auth_token=None, user=None, tenant=None, domain=None,
#                  user_domain=None, project_domain=None, is_admin=False,
#                  read_only=False, show_deleted=False, request_id=None,
#                  resource_uuid=None, overwrite=True, roles=None):
#     def from_dict(cls, values):
#     def elevated(self, show_deleted=False):
#     def view_deleted(self):
# def get_admin_context(show_deleted="no"):
# def get_current():


import unittest
from freezer_api import context
# limitations under the License.




class TestFreezerContext(unittest.TestCase):

    def setUp(self):
        self.ctxt = context.FreezerContext('token01', 'user01', 'tenant01',
                                           is_admin=False,
                                           roles=['_member', 'backup_admin'])

    def test_not_admin(self):
        ctxt = context.get_current()
        self.assertEqual(False, ctxt.is_admin)

    def test_privileges_elevated(self):
        self.ctxt = self.ctxt.elevated('yes')
        self.assertTrue(self.ctxt.is_admin)
        self.assertEqual('yes', self.ctxt.show_deleted)

    def test_admin_context(self):
        admin_ctxt = context.get_admin_context(show_deleted='yes')
        self.assertTrue(admin_ctxt.is_admin)
        self.assertEqual('yes', admin_ctxt.show_deleted)

    def test_from_dict(self):
        ctxt_dict = {'user': 'user02',
                     'tenant': 'tenant03',
                     'roles': ['_member', 'member']}

# Path: freezer_api/context.py
# LOG = log.getLogger(__name__)
# class FreezerContext(context.RequestContext):
#     def __init__(self, auth_token=None, user=None, tenant=None, domain=None,
#                  user_domain=None, project_domain=None, is_admin=False,
#                  read_only=False, show_deleted=False, request_id=None,
#                  resource_uuid=None, overwrite=True, roles=None):
#     def from_dict(cls, values):
#     def elevated(self, show_deleted=False):
#     def view_deleted(self):
# def get_admin_context(show_deleted="no"):
# def get_current():


# Path: freezer_api/tests/unit/test_context.py
import unittest
from freezer_api import context

# limitations under the License.




class TestFreezerContext(unittest.TestCase):

    def setUp(self):
        self.ctxt = context.FreezerContext('token01', 'user01', 'tenant01',
                                           is_admin=False,
                                           roles=['_member', 'backup_admin'])

    def test_not_admin(self):
        ctxt = context.get_current()
        self.assertEqual(False, ctxt.is_admin)

    def test_privileges_elevated(self):
        self.ctxt = self.ctxt.elevated('yes')
        self.assertTrue(self.ctxt.is_admin)
        self.assertEqual('yes', self.ctxt.show_deleted)

    def test_admin_context(self):
        admin_ctxt = context.get_admin_context(show_deleted='yes')
        self.assertTrue(admin_ctxt.is_admin)
        self.assertEqual('yes', admin_ctxt.show_deleted)

    def test_from_dict(self):
        ctxt_dict = {'user': 'user02',
                     'tenant': 'tenant03',
                     'roles': ['_member', 'member']}

        ctxt = context.FreezerContext.from_dict(ctxt_dict)