# (c) cavaliba.com - test_home

# import io

from django.test import TestCase


import app_home.cache as cache
from app_home.configuration import get_configuration


class ConfTest(TestCase):

    fixtures = ["init"]

    def setUp(self):
        cache.clear()

    def test_test(self):
        self.assertEqual(True, True)

    def test_get_configuration(self):

        r = get_configuration("home", "GLOBAL_APPNAME")
        self.assertEqual(r, 'Cavaliba')

        r = get_configuration(keyname="GLOBAL_APPNAME")
        self.assertEqual(r, 'Cavaliba')

        r = get_configuration("env", "CAVALIBA_AUTH_MODE")
        # self.assertEqual(r, 'local')
        self.assertIn(r, ["local", "oauth2", "basic", "forced"])

    def test_conf_no_skip_public(self):
        r = get_configuration("sirene", "PUBLIC_SKIP_TO_TRUSTED")
        self.assertEqual(r, 'no')

