# Path: mozsvc/config.py
# def load_into_settings(filename, settings):
# def get_configurator(global_config, **settings):


import unittest
import tempfile
import os
from io import StringIO
from mozsvc.config import (Config, SettingsDict, load_into_settings,
                           get_configurator)

    def tearDown(self):
        if '__STUFF__' in os.environ:
            del os.environ['__STUFF__']
        os.remove(self.file_two)

    def test_reader(self):
        config = Config(self.file_one)

        # values conversion
        self.assertEqual(config.get('one', 'foo'), 'bar')
        self.assertEqual(config.get('one', 'num'), -12)
        self.assertEqual(config.get('one', 'st'), 'o=k')
        self.assertEqual(config.get('one', 'lines'), [1, 'two', 3])
        self.assertEqual(config.get('one', 'env'), 'some stuff')

        # getting a map
        map = config.get_map()
        self.assertEqual(map['one.foo'], 'bar')

        map = config.get_map('one')
        self.assertEqual(map['foo'], 'bar')

        # extends
        self.assertEqual(config.get('three', 'more'), 'stuff')
        self.assertEqual(config.get('one', 'two'), 'a')

    def test_nofile(self):
        # if a user tries to use an inexistant file in extensions,
        # pops an error

# Path: mozsvc/config.py
# def load_into_settings(filename, settings):
# def get_configurator(global_config, **settings):


# Path: mozsvc/tests/test_config.py
import unittest
import tempfile
import os
from io import StringIO
from mozsvc.config import (Config, SettingsDict, load_into_settings,
                           get_configurator)


    def tearDown(self):
        if '__STUFF__' in os.environ:
            del os.environ['__STUFF__']
        os.remove(self.file_two)

    def test_reader(self):
        config = Config(self.file_one)

        # values conversion
        self.assertEqual(config.get('one', 'foo'), 'bar')
        self.assertEqual(config.get('one', 'num'), -12)
        self.assertEqual(config.get('one', 'st'), 'o=k')
        self.assertEqual(config.get('one', 'lines'), [1, 'two', 3])
        self.assertEqual(config.get('one', 'env'), 'some stuff')

        # getting a map
        map = config.get_map()
        self.assertEqual(map['one.foo'], 'bar')

        map = config.get_map('one')
        self.assertEqual(map['foo'], 'bar')

        # extends
        self.assertEqual(config.get('three', 'more'), 'stuff')
        self.assertEqual(config.get('one', 'two'), 'a')

    def test_nofile(self):
        # if a user tries to use an inexistant file in extensions,
        # pops an error

        self.assertRaises(IOError, Config, self.file_three)