# Path: habitat/utils/startup.py
# def load_config():
# def _get_logging_level(value):
#     def emit(self, record):
# def setup_logging(config, daemon_name):
# def main(main_class):
# class null_logger(logging.Handler):


import sys
import tempfile
import mox
import smtplib
import copy
import logging
import os
import os.path
from ...utils import startup


_example_yaml = \
"""d: 4
blah: moo
o:
    listy:
       - 2
       - cow"""

_example_parsed = {"d": 4, "blah": "moo", "o": {"listy": [2, "cow"]}}

class TestLoadConfig(object):
    def setup(self):
        self.config = tempfile.NamedTemporaryFile()
        self.old_argv = sys.argv
        sys.argv = ["bin/something", self.config.name]

    def teardown(self):
        sys.argv = self.old_argv
        self.config.close()

    def test_works(self):
        self.config.write(_example_yaml)
        self.config.flush()
        assert startup.load_config() == _example_parsed

_logging_config = {
    "log_levels": {},
    "log_emails": {"to": ["addr_1", "addr_2"], "from": "from_bob",

# Path: habitat/utils/startup.py
# def load_config():
# def _get_logging_level(value):
#     def emit(self, record):
# def setup_logging(config, daemon_name):
# def main(main_class):
# class null_logger(logging.Handler):


# Path: habitat/tests/test_utils/test_startup.py
import sys
import tempfile
import mox
import smtplib
import copy
import logging
import os
import os.path
from ...utils import startup



_example_yaml = \
"""d: 4
blah: moo
o:
    listy:
       - 2
       - cow"""

_example_parsed = {"d": 4, "blah": "moo", "o": {"listy": [2, "cow"]}}

class TestLoadConfig(object):
    def setup(self):
        self.config = tempfile.NamedTemporaryFile()
        self.old_argv = sys.argv
        sys.argv = ["bin/something", self.config.name]

    def teardown(self):
        sys.argv = self.old_argv
        self.config.close()

    def test_works(self):
        self.config.write(_example_yaml)
        self.config.flush()
        assert startup.load_config() == _example_parsed

_logging_config = {
    "log_levels": {},
    "log_emails": {"to": ["addr_1", "addr_2"], "from": "from_bob",

                   "server": "email_server"},