Ejemplo n.º 1
0
 def test_invalid_line(self):
     self.tmpfile.write('justkey\n'.encode('utf8'))
     self.tmpfile.flush()
     assert_raises(
             errors.ConfigurationError,
             loader.PropertiesConfiguration,
             self.tmpfile.name)
Ejemplo n.º 2
0
    def test_build_loader_optional(self):
        err_msg = "Failed to do"
        loader_func = mock.Mock()
        loader_func.side_effect = ValueError(err_msg)
        config_loader = loader.build_loader(loader_func)

        config_loader(optional=True)
        assert_raises(ValueError, config_loader)
 def test_read_config_failed(self):
     self.namespace.get.return_value = proxy.UndefToken
     assert_raises(
             errors.ConfigurationError,
             readers._read_config,
             'some_key',
             self.namespace,
             None)
    def test_mock_configuration_context_manager(self):
        one = self.getters.get('one')
        three = self.getters.get_int('three', default=3)

        with testing.MockConfiguration(dict(one=7), namespace=self.namespace):
            assert_equal(one, 7)
            assert_equal(three, 3)
        assert_raises(errors.ConfigurationError, self.getters.get('one'))
    def test_mock_configuration_context_manager(self):
        one = self.getters.get('one')
        three = self.getters.get_int('three', default=3)

        with testing.MockConfiguration(dict(one=7), namespace=self.namespace):
            assert_equal(one, 7)
            assert_equal(three, 3)
        assert_raises(errors.ConfigurationError, self.getters.get('one'))
Ejemplo n.º 6
0
 def test_has_duplicate_keys_raises(self):
     config_data = dict(fear=123)
     assert_raises(
             errors.ConfigurationError,
             config.has_duplicate_keys,
             config_data,
             self.base_conf,
             True)
Ejemplo n.º 7
0
    def test_build_loader_optional(self):
        err_msg = "Failed to do"
        loader_func = mock.Mock()
        loader_func.side_effect = ValueError(err_msg)
        config_loader = loader.build_loader(loader_func)

        config_loader(optional=True)
        assert_raises(ValueError, config_loader)
Ejemplo n.º 8
0
    def test_validate_value_token(self):
        class ExampleSchema(schema.Schema):
            namespace = 'DEFAULT'

            thing = schema.int()

        assert_raises(errors.ConfigurationError,
                      config.validate,
                      all_names=True)
Ejemplo n.º 9
0
    def test_validate_value_token(self):
        class ExampleSchema(schema.Schema):
            namespace = 'DEFAULT'

            thing = schema.int()

        assert_raises(errors.ConfigurationError,
                      config.validate,
                      all_names=True)
    def test_mock_configuration(self):
        two = self.getters.get_string('two')
        stars = self.getters.get_bool('stars')

        mock_config = testing.MockConfiguration(
            dict(two=2, stars=False), namespace=self.namespace)
        mock_config.setup()
        assert_equal(two, '2')
        assert not stars
        mock_config.teardown()
        assert_raises(errors.ConfigurationError, self.getters.get('two'))
Ejemplo n.º 11
0
 def test_xml_configuration_safe_value_tag(self):
     content = """
         <config>
             <sometag value="snazz">E</sometag>
         </config>
     """
     self.write_content_to_file(content)
     assert_raises(errors.ConfigurationError,
                   loader.XMLConfiguration,
                   self.tmpfile.name,
                   safe=True)
    def test_mock_configuration(self):
        two = self.getters.get_string('two')
        stars = self.getters.get_bool('stars')

        mock_config = testing.MockConfiguration(dict(two=2, stars=False),
                                                namespace=self.namespace)
        mock_config.setup()
        assert_equal(two, '2')
        assert not stars
        mock_config.teardown()
        assert_raises(errors.ConfigurationError, self.getters.get('two'))
Ejemplo n.º 13
0
 def test_xml_configuration_safe_value_tag(self):
     content = """
         <config>
             <sometag value="snazz">E</sometag>
         </config>
     """
     self.write_content_to_file(content)
     assert_raises(
             errors.ConfigurationError,
             loader.XMLConfiguration,
             self.tmpfile.name,
             safe=True)
Ejemplo n.º 14
0
 def test_xml_configuration_safe_override(self):
     content = """
         <config>
             <sometag foo="bar">
                 <foo>E</foo>
             </sometag>
         </config>
     """
     self.write_content_to_file(content)
     assert_raises(errors.ConfigurationError,
                   loader.XMLConfiguration,
                   self.tmpfile.name,
                   safe=True)
Ejemplo n.º 15
0
 def test_xml_configuration_safe_override(self):
     content = """
         <config>
             <sometag foo="bar">
                 <foo>E</foo>
             </sometag>
         </config>
     """
     self.write_content_to_file(content)
     assert_raises(
             errors.ConfigurationError,
             loader.XMLConfiguration,
             self.tmpfile.name,
             safe=True)
Ejemplo n.º 16
0
 def test_get_namespace_missing(self, meta_schema):
     meta, _, _ = meta_schema
     assert_raises(errors.ConfigurationError, meta.get_namespace, {})
Ejemplo n.º 17
0
 def test_auto_failed(self):
     assert_raises(errors.ConfigurationError, loader.AutoConfiguration)
Ejemplo n.º 18
0
 def test_read_config_failed(self):
     self.namespace.get.return_value = proxy.UndefToken
     assert_raises(errors.ConfigurationError, readers._read_config,
                   'some_key', self.namespace, None)
Ejemplo n.º 19
0
 def test_validate_keys_unknown_raise(self):
     assert_raises(errors.ConfigurationError, self.namespace.validate_keys,
                   self.config_data, True)
Ejemplo n.º 20
0
 def test_validate_keys_unknown_raise(self):
     assert_raises(errors.ConfigurationError,
             self.namespace.validate_keys, self.config_data, True)
Ejemplo n.º 21
0
 def test_validate_all_fails(self):
     name = 'yan'
     _ = staticconf.get_string('foo', namespace=name)  # flake8: noqa
     assert_raises(errors.ConfigurationError,
                   config.validate,
                   all_names=True)
Ejemplo n.º 22
0
 def test_invalid_line(self):
     self.tmpfile.write('justkey\n'.encode('utf8'))
     self.tmpfile.flush()
     assert_raises(errors.ConfigurationError,
                   loader.PropertiesConfiguration, self.tmpfile.name)
Ejemplo n.º 23
0
 def test_get_namespace_missing(self, meta_schema):
     meta, _, _ = meta_schema
     assert_raises(errors.ConfigurationError, meta.get_namespace, {})
Ejemplo n.º 24
0
 def test_validate_all_fails(self):
     name = 'yan'
     _ = staticconf.get_string('foo', namespace=name)  # noqa: F841
     assert_raises(errors.ConfigurationError,
                   config.validate,
                   all_names=True)
Ejemplo n.º 25
0
 def test_validate_single_fails(self):
     _ = staticconf.get_int('one.two')  # noqa: F841
     assert_raises(errors.ConfigurationError, config.validate)
Ejemplo n.º 26
0
 def test_auto_failed(self):
     assert_raises(errors.ConfigurationError, loader.AutoConfiguration)
Ejemplo n.º 27
0
 def test_validate_single_fails(self):
     _ = staticconf.get_int('one.two')
     assert_raises(errors.ConfigurationError, config.validate)