def test_globals(self):
        """extract_ini_context() accepts input with no sections."""
        data = """global1 = g1
global2 = g2

[section1]
option1 = o1
option2 = o2
"""
        request = self.request_factory(data)
        context = contextextractors.extract_ini_context(request)
        self.assertEqual(context, {'global1': 'g1',
                                   'global2': 'g2',
                                   'section1': {'option1': 'o1',
                                                'option2': 'o2'}})
    def test_config_parser(self):
        """extract_ini_context() accepts standard ConfigParser input."""
        data = """[section1]
option1 = 1
option2 = 2

[section2]
optiona = A
optionb = B
"""
        request = self.request_factory(data)
        context = contextextractors.extract_ini_context(request)
        self.assertEqual(context, {'section1': {'option1': '1',
                                                'option2': '2'},
                                   'section2': {'optiona': 'A',
                                                'optionb': 'B'}})
    def test_globals(self):
        """extract_ini_context() accepts input with no sections."""
        data = """global1 = g1
global2 = g2

[section1]
option1 = o1
option2 = o2
"""
        request = self.request_factory(data)
        context = contextextractors.extract_ini_context(request)
        self.assertEqual(
            context, {
                'global1': 'g1',
                'global2': 'g2',
                'section1': {
                    'option1': 'o1',
                    'option2': 'o2'
                }
            })
    def test_config_parser(self):
        """extract_ini_context() accepts standard ConfigParser input."""
        data = """[section1]
option1 = 1
option2 = 2

[section2]
optiona = A
optionb = B
"""
        request = self.request_factory(data)
        context = contextextractors.extract_ini_context(request)
        self.assertEqual(
            context, {
                'section1': {
                    'option1': '1',
                    'option2': '2'
                },
                'section2': {
                    'optiona': 'A',
                    'optionb': 'B'
                }
            })
 def test_empty(self):
     """extract_ini_context() with empty data returns empty context."""
     data = u''
     request = self.request_factory(data)
     context = contextextractors.extract_ini_context(request)
     self.assertEqual(context, {})
 def test_empty(self):
     """extract_ini_context() with empty data returns empty context."""
     data = u''
     request = self.request_factory(data)
     context = contextextractors.extract_ini_context(request)
     self.assertEqual(context, {})