# Path: servi/config.py
# def deep_update(orig_dict, new_dict):
#     # Given a new dict, update the orig dict deeply
#     # eg: {a: {a1: 1}} , {a: {a2: 2}} --> {a: {a1: 1, a2:2 }}
#     # Note - this means new_dict  >= orig_dict
#     # http://stackoverflow.com/a/3233356/1400991
#     for key, val in new_dict.items():
#         if isinstance(val, collections.Mapping):
#             tmp = deep_update(orig_dict.get(key, {}), val)
#             orig_dict[key] = tmp
#         else:
#             orig_dict[key] = new_dict[key]
#     return orig_dict
# 
# Path: servi/exceptions.py
# class ServiError(Exception):
#     # Expected errrors. Handle gracefully (ie: no stack dump)
#     def __init__(self, msg=None):
#         self.msg = msg
# 
#     def __str__(self):
#         return (
#             '\n***** ERROR *****\n'
#             '{0}\n'
#             '\n**Servi Aborting**'.format(self.msg))


from pprint import pprint
from jinja2 import Environment, DictLoader
from tests.fixtures import *
from servi.config import deep_update
from servi.exceptions import ServiError
import servi.config as c




@pytest.fixture(scope="module", autouse=True)
def config_fixture():
    os.environ['SERVI_TEST'] = '12345'


def test_lookup_fn():
    # Test the jinja2 lookup function


# Path: servi/config.py
# def deep_update(orig_dict, new_dict):
#     # Given a new dict, update the orig dict deeply
#     # eg: {a: {a1: 1}} , {a: {a2: 2}} --> {a: {a1: 1, a2:2 }}
#     # Note - this means new_dict  >= orig_dict
#     # http://stackoverflow.com/a/3233356/1400991
#     for key, val in new_dict.items():
#         if isinstance(val, collections.Mapping):
#             tmp = deep_update(orig_dict.get(key, {}), val)
#             orig_dict[key] = tmp
#         else:
#             orig_dict[key] = new_dict[key]
#     return orig_dict
# 
# Path: servi/exceptions.py
# class ServiError(Exception):
#     # Expected errrors. Handle gracefully (ie: no stack dump)
#     def __init__(self, msg=None):
#         self.msg = msg
# 
#     def __str__(self):
#         return (
#             '\n***** ERROR *****\n'
#             '{0}\n'
#             '\n**Servi Aborting**'.format(self.msg))


# Path: tests/test_config.py
from pprint import pprint
from jinja2 import Environment, DictLoader
from tests.fixtures import *
from servi.config import deep_update
from servi.exceptions import ServiError
import servi.config as c





@pytest.fixture(scope="module", autouse=True)
def config_fixture():
    os.environ['SERVI_TEST'] = '12345'


def test_lookup_fn():
    # Test the jinja2 lookup function


    with pytest.raises(ServiError):