# Path: django_docker_helpers/utils.py
# def default_yaml_object_deserialize(stream, Loader=SafeLoader):
# def shred(key_name: str,
#           value: t.Any,
#           field_names: t.Iterable[str] = SHRED_DATA_FIELD_NAMES) -> t.Union[t.Any, str]:
# def shred_deep(value, field_names: t.Iterable[str] = SHRED_DATA_FIELD_NAMES):
# def import_from(module: str, name: str):
# def dot_path(obj: t.Union[t.Dict, object],
#              path: str,
#              default: t.Any = None,
#              separator: str = '.'):
# def dotkey(obj: dict, path: str, default=None, separator='.'):
# def _materialize_dict(bundle: dict, separator: str = '.') -> t.Generator[t.Tuple[str, t.Any], None, None]:
# def materialize_dict(bundle: dict, separator: str = '.') -> t.List[t.Tuple[str, t.Any]]:
#     def _matkeysort(tup: t.Tuple[str, t.Any]):
# def mp_serialize_dict(
#         bundle: dict,
#         separator: str = '.',
#         serialize: t.Optional[t.Callable] = dump_yaml,
#         value_prefix: str = '::YAML::\n') -> t.List[t.Tuple[str, bytes]]:
# def wf(raw_str: str,
#        flush: bool = True,
#        prevent_completion_polluting: bool = True,
#        stream: t.TextIO = sys.stdout):
# def coerce_str_to_bool(val: t.Union[str, int, bool, None], strict: bool = False) -> bool:
# def env_bool_flag(flag_name: str, strict: bool = False, env: t.Optional[t.Dict[str, str]] = None) -> bool:
# def env_tristate_flag(flag_name: str, strict: bool = False, env: t.Optional[t.Dict[str, str]] = None) -> t.Optional[bool]:
# def _build_cache_key_for_env(*args, **kwargs) -> str:
# def run_env_once(f: t.Callable) -> t.Callable:
#     def wrapper(*args, **kwargs):
# def is_dockerized(flag_name: str = 'DOCKERIZED', strict: bool = False) -> bool:
# def is_production(flag_name: str = 'PRODUCTION', strict: bool = False) -> bool:
# ENV_STR_BOOL_COERCE_MAP = {
#     '': True,  # Flag is set
# 
#     0: False,
#     '0': False,
#     'false': False,
#     'off': False,
# 
#     1: True,
#     '1': True,
#     'true': True,
#     'on': True,
# }
# SHRED_DATA_FIELD_NAMES = (
#     'password',
#     'secret',
#     'pass',
#     'pwd',
#     'key',
#     'token',
#     'auth',
#     'cred',
# )


import pytest
import os
from unittest import mock
from django_docker_helpers import utils
class UtilsTest:
    def test__utils__dotkey(self):
        obj = {
            'debug': True,
            'first': 1,
            'second': {
                'nested': True,
                'next': [1, 2, 3]
            }
        }
        assert utils.dotkey(obj, 'debug') is True
        assert utils.dotkey(obj, 'first') == 1
        assert utils.dotkey(obj, 'second') == {'nested': True, 'next': [1, 2, 3]}
        assert utils.dotkey(obj, 'second.next.1') == 2
        assert utils.dotkey(obj, 'second.lol', 'DEFAULT') == 'DEFAULT'

    def test__coerce_str_to_bool(self):
        assert utils.coerce_str_to_bool('0') is False
        assert utils.coerce_str_to_bool('1') is True

        assert utils.coerce_str_to_bool('FALSE') is False
        assert utils.coerce_str_to_bool('true') is True

        assert utils.coerce_str_to_bool('off') is False
        assert utils.coerce_str_to_bool('on') is True

        assert utils.coerce_str_to_bool(False) is False
        assert utils.coerce_str_to_bool(True) is True

        assert utils.coerce_str_to_bool(0) is False

# Path: django_docker_helpers/utils.py
# def default_yaml_object_deserialize(stream, Loader=SafeLoader):
# def shred(key_name: str,
#           value: t.Any,
#           field_names: t.Iterable[str] = SHRED_DATA_FIELD_NAMES) -> t.Union[t.Any, str]:
# def shred_deep(value, field_names: t.Iterable[str] = SHRED_DATA_FIELD_NAMES):
# def import_from(module: str, name: str):
# def dot_path(obj: t.Union[t.Dict, object],
#              path: str,
#              default: t.Any = None,
#              separator: str = '.'):
# def dotkey(obj: dict, path: str, default=None, separator='.'):
# def _materialize_dict(bundle: dict, separator: str = '.') -> t.Generator[t.Tuple[str, t.Any], None, None]:
# def materialize_dict(bundle: dict, separator: str = '.') -> t.List[t.Tuple[str, t.Any]]:
#     def _matkeysort(tup: t.Tuple[str, t.Any]):
# def mp_serialize_dict(
#         bundle: dict,
#         separator: str = '.',
#         serialize: t.Optional[t.Callable] = dump_yaml,
#         value_prefix: str = '::YAML::\n') -> t.List[t.Tuple[str, bytes]]:
# def wf(raw_str: str,
#        flush: bool = True,
#        prevent_completion_polluting: bool = True,
#        stream: t.TextIO = sys.stdout):
# def coerce_str_to_bool(val: t.Union[str, int, bool, None], strict: bool = False) -> bool:
# def env_bool_flag(flag_name: str, strict: bool = False, env: t.Optional[t.Dict[str, str]] = None) -> bool:
# def env_tristate_flag(flag_name: str, strict: bool = False, env: t.Optional[t.Dict[str, str]] = None) -> t.Optional[bool]:
# def _build_cache_key_for_env(*args, **kwargs) -> str:
# def run_env_once(f: t.Callable) -> t.Callable:
#     def wrapper(*args, **kwargs):
# def is_dockerized(flag_name: str = 'DOCKERIZED', strict: bool = False) -> bool:
# def is_production(flag_name: str = 'PRODUCTION', strict: bool = False) -> bool:
# ENV_STR_BOOL_COERCE_MAP = {
#     '': True,  # Flag is set
# 
#     0: False,
#     '0': False,
#     'false': False,
#     'off': False,
# 
#     1: True,
#     '1': True,
#     'true': True,
#     'on': True,
# }
# SHRED_DATA_FIELD_NAMES = (
#     'password',
#     'secret',
#     'pass',
#     'pwd',
#     'key',
#     'token',
#     'auth',
#     'cred',
# )


# Path: tests/test_utils.py
import pytest
import os
from unittest import mock
from django_docker_helpers import utils

class UtilsTest:
    def test__utils__dotkey(self):
        obj = {
            'debug': True,
            'first': 1,
            'second': {
                'nested': True,
                'next': [1, 2, 3]
            }
        }
        assert utils.dotkey(obj, 'debug') is True
        assert utils.dotkey(obj, 'first') == 1
        assert utils.dotkey(obj, 'second') == {'nested': True, 'next': [1, 2, 3]}
        assert utils.dotkey(obj, 'second.next.1') == 2
        assert utils.dotkey(obj, 'second.lol', 'DEFAULT') == 'DEFAULT'

    def test__coerce_str_to_bool(self):
        assert utils.coerce_str_to_bool('0') is False
        assert utils.coerce_str_to_bool('1') is True

        assert utils.coerce_str_to_bool('FALSE') is False
        assert utils.coerce_str_to_bool('true') is True

        assert utils.coerce_str_to_bool('off') is False
        assert utils.coerce_str_to_bool('on') is True

        assert utils.coerce_str_to_bool(False) is False
        assert utils.coerce_str_to_bool(True) is True

        assert utils.coerce_str_to_bool(0) is False

        assert utils.coerce_str_to_bool(1) is True