def test_pastes_debug(self):
     """Django's "DEBUG" must be set to Paster's "debug"."""
     global_conf = {"debug": "true"}
     local_conf = {}
     settings = _convert_options(global_conf, local_conf)
     self.assertIn("DEBUG", settings)
     self.assertEqual(settings["DEBUG"], True)
Example #2
0
 def test_pastes_debug(self):
     """Django's "DEBUG" must be set to Paster's "debug"."""
     global_conf = {'debug': "true"}
     local_conf = {}
     settings = _convert_options(global_conf, local_conf)
     ok_("DEBUG" in settings)
     eq_(settings['DEBUG'], True)
    def test_custom_integer(self):
        """Custom integers should be converted."""
        global_conf = {"debug": "yes", "twod.integers": ("myint",)}
        local_conf = {"myint": "3"}
        settings = _convert_options(global_conf, local_conf)

        self.assertEqual(settings["myint"], 3)
        self.assertNotIn("twod.integers", settings)
    def test_custom_boolean(self):
        """Custom booleans should be converted."""
        global_conf = {"debug": "yes", "twod.booleans": ("mybool",)}
        local_conf = {"mybool": "no"}
        settings = _convert_options(global_conf, local_conf)

        self.assertEqual(settings["mybool"], False)
        self.assertNotIn("twod.booleans", settings)
    def test_custom_dictionary(self):
        """Custom dictionaries should be converted."""
        items = ("foo = bar", "baz=abc", " xyz = mno ")
        global_conf = {"debug": "yes", "twod.dictionaries": ("mydict",)}
        local_conf = {"mydict": "\n " + "\n    ".join(items)}
        settings = _convert_options(global_conf, local_conf)

        self.assertEqual(settings["mydict"], {"foo": "bar", "baz": "abc", "xyz": "mno"})
        self.assertNotIn("twod.dictionaries", settings)
    def test_custom_tuple(self):
        """Custom tuples should be converted."""
        items = ("foo", "bar", "baz")
        global_conf = {"debug": "yes", "twod.tuples": ("mytuple",)}
        local_conf = {"mytuple": "\n " + "\n    ".join(items)}
        settings = _convert_options(global_conf, local_conf)

        self.assertEqual(settings["mytuple"], items)
        self.assertNotIn("twod.tuples", settings)
Example #7
0
 def test__file__is_ignored(self):
     """The __file__ argument must be renamed to paste_configuration_file."""
     global_conf = {'debug': "yes", '__file__': "somewhere"}
     local_conf = {}
     
     settings = _convert_options(global_conf, local_conf)
     
     ok_("__file__" not in settings)
     ok_("paste_configuration_file" in settings)
     eq_(settings['paste_configuration_file'], "somewhere")
    def test__file__is_ignored(self):
        """The __file__ argument must be renamed to paste_configuration_file."""
        global_conf = {"debug": "yes", "__file__": "somewhere"}
        local_conf = {}

        settings = _convert_options(global_conf, local_conf)

        self.assertNotIn("__file__", settings)
        self.assertIn("paste_configuration_file", settings)
        self.assertEqual(settings["paste_configuration_file"], "somewhere")
    def test_non_if_empty_non_empty_settings(self):
        """Non-empty 'none if empty' settings are left as strings."""

        global_conf = {"debug": "yes", "twod.none_if_empty_settings": ("mynone", "mynonewithspace")}
        local_conf = {"mynone": "I am a string", "mynonewithspace": " I am a string "}
        settings = _convert_options(global_conf, local_conf)

        self.assertEqual(settings["mynone"], "I am a string")
        self.assertEqual(settings["mynonewithspace"], "I am a string")
        self.assertNotIn("twod.none_if_empty_settings", settings)
Example #10
0
    def test_custom_none_if_empty_settings(self):
        """Custom NoneTypes should be converted."""

        global_conf = {"debug": "yes", "twod.none_if_empty_settings": ("mynone", "mynonewithspace")}
        local_conf = {"mynone": "", "mynonewithspace": "    "}
        settings = _convert_options(global_conf, local_conf)

        self.assertIsNone(settings["mynone"])
        self.assertIsNone(settings["mynonewithspace"])
        self.assertNotIn("twod.none_if_empty_settings", settings)
Example #11
0
    def test_official_integers(self):
        """Django's integer settings must be converted."""
        for setting_name in _DJANGO_INTEGERS:
            global_conf = {"debug": "yes"}
            local_conf = {setting_name: 2}
            settings = _convert_options(global_conf, local_conf)

            self.assertEqual(
                settings[setting_name], 2, "%s must be a integer, but it is %r" % (setting_name, settings[setting_name])
            )
Example #12
0
 def test_official_nested_tuples(self):
     """Django's nested tuple settings must be converted."""
     items = ("foo;the bar;  baz", "bar ;foo", "baz")
     nested_items = (("foo", "the bar", "baz"), ("bar", "foo"), ("baz",))
     
     for setting_name in _DJANGO_NESTED_TUPLES:
         global_conf = {'debug': "yes"}
         local_conf = {setting_name: "\n " + "\n    ".join(items)}
         settings = _convert_options(global_conf, local_conf)
         
         eq_(settings[setting_name], nested_items)
Example #13
0
 def test_custom_boolean(self):
     """Custom booleans should be converted."""
     global_conf = {
         'debug': "yes",
         'twod.booleans': ("mybool", ),
         }
     local_conf = {'mybool': "no"}
     settings = _convert_options(global_conf, local_conf)
     
     eq_(settings['mybool'], False)
     assert_false("twod.booleans" in settings)
Example #14
0
    def test_official_none_if_empty_settings(self):
        """Django's settings which are None if unspecified must be converted."""

        for setting_name in _DJANGO_NONE_IF_EMPTY_SETTINGS:
            global_conf = {"debug": "yes"}
            local_conf = {setting_name: ""}
            settings = _convert_options(global_conf, local_conf)

            self.assertIsNone(
                settings[setting_name], "%s must be NoneType, but it is %r" % (setting_name, settings[setting_name])
            )
Example #15
0
 def test_custom_integer(self):
     """Custom integers should be converted."""
     global_conf = {
         'debug': "yes",
         'twod.integers': ("myint", ),
         }
     local_conf = {'myint': "3"}
     settings = _convert_options(global_conf, local_conf)
     
     eq_(settings['myint'], 3)
     assert_false("twod.integers" in settings)
Example #16
0
    def test_custom_nested_tuple(self):
        """Custom nested tuples should be converted."""
        items = ("foo;the bar;  baz", "bar ;foo", "baz")
        nested_items = (("foo", "the bar", "baz"), ("bar", "foo"), ("baz",))
        global_conf = {"debug": "yes", "twod.nested_tuples": ("my_nested_tuple",)}
        local_conf = {"my_nested_tuple": "\n " + "\n    ".join(items)}

        settings = _convert_options(global_conf, local_conf)

        self.assertEqual(settings["my_nested_tuple"], nested_items)
        self.assertNotIn("twod.nested_tuples", settings)
Example #17
0
 def test_official_integers(self):
     """Django's integer settings must be converted."""
     for setting_name in _DJANGO_INTEGERS:
         global_conf = {'debug': "yes"}
         local_conf = {setting_name: 2}
         settings = _convert_options(global_conf, local_conf)
         
         eq_(settings[setting_name],
             2,
             "%s must be a integer, but it is %r" % (setting_name,
                                                     settings[setting_name]),
             )
Example #18
0
 def test_custom_integer(self):
     """Custom integers should be converted."""
     global_conf = {
         'debug': "yes",
         'twod.integers': ("myint", ),
         }
     local_conf = {'myint': "3"}
     settings = _convert_options(global_conf, local_conf)
     
     eq_(settings['myint'], 3)
     # "twod.integers" should have not been added:
     assert_false("twod.integers" in settings)
Example #19
0
 def test_custom_boolean(self):
     """Custom booleans should be converted."""
     global_conf = {
         'debug': "yes",
         'twod.booleans': ("mybool", ),
         }
     local_conf = {'mybool': "no"}
     settings = _convert_options(global_conf, local_conf)
     
     eq_(settings['mybool'], False)
     # "twod.booleans" should have not been added:
     assert_false("twod.booleans" in settings)
Example #20
0
 def test_strings(self):
     """
     Values whose values are not requested to be converted should be kept as
     is.
     
     """
     global_conf = {'debug': "yes"}
     local_conf = {'parameter': "value"}
     settings = _convert_options(global_conf, local_conf)
     
     ok_("parameter" in settings)
     eq_(settings['parameter'], "value")
Example #21
0
    def test_strings(self):
        """
        Values whose values are not requested to be converted should be kept as
        is.
        
        """
        global_conf = {"debug": "yes"}
        local_conf = {"parameter": "value"}
        settings = _convert_options(global_conf, local_conf)

        self.assertIn("parameter", settings)
        self.assertEqual(settings["parameter"], "value")
Example #22
0
 def test_official_tuples(self):
     """Django's tuple settings must be converted."""
     items = ("foo", "bar", "baz")
     for setting_name in _DJANGO_TUPLES:
         global_conf = {'debug': "yes"}
         local_conf = {setting_name: "\n " + "\n    ".join(items)}
         settings = _convert_options(global_conf, local_conf)
         
         eq_(settings[setting_name], items,
             "%s must be a tuple, but it is %r" % (setting_name,
                                                   settings[setting_name]),
             )
Example #23
0
 def test_custom_dictionary(self):
     """Custom dictionaries should be converted."""
     items = ("foo = bar", "baz=abc", " xyz = mno ")
     global_conf = {
         'debug': "yes",
         'twod.dictionaries': ("mydict", ),
         }
     local_conf = {'mydict': "\n " + "\n    ".join(items)}
     settings = _convert_options(global_conf, local_conf)
     
     eq_(settings['mydict'], {'foo': "bar", 'baz': "abc", 'xyz': "mno"})
     assert_false("twod.dictionaries" in settings)
Example #24
0
 def test_custom_tuple(self):
     """Custom tuples should be converted."""
     items = ("foo", "bar", "baz")
     global_conf = {
         'debug': "yes",
         'twod.tuples': ("mytuple", ),
         }
     local_conf = {'mytuple': "\n " + "\n    ".join(items)}
     settings = _convert_options(global_conf, local_conf)
     
     eq_(settings['mytuple'], items)
     assert_false("twod.tuples" in settings)
Example #25
0
 def test_custom_tuple(self):
     """Custom tuples should be converted."""
     items = ("foo", "bar", "baz")
     global_conf = {
         'debug': "yes",
         'twod.tuples': ("mytuple", ),
         }
     local_conf = {'mytuple': "\n " + "\n    ".join(items)}
     settings = _convert_options(global_conf, local_conf)
     
     eq_(settings['mytuple'], items)
     # "twod.tuples" should have not been added:
     assert_false("twod.tuples" in settings)
Example #26
0
    def test_custom_none_if_empty_settings(self):
        """Custom NoneTypes should be converted."""

        global_conf = {
            'debug': "yes",
            'twod.none_if_empty_settings': ("mynone", "mynonewithspace"),
            }
        local_conf = {'mynone': '', 'mynonewithspace': '    '}
        settings = _convert_options(global_conf, local_conf)
        
        ok_(settings['mynone'] is None)
        ok_(settings['mynonewithspace'] is None)
        assert_false("twod.none_if_empty_settings" in settings)
Example #27
0
 def test_custom_dictionary(self):
     """Custom dictionaries should be converted."""
     items = ("foo = bar", "baz=abc", " xyz = mno ")
     global_conf = {
         'debug': "yes",
         'twod.dictionaries': ("mydict", ),
         }
     local_conf = {'mydict': "\n " + "\n    ".join(items)}
     settings = _convert_options(global_conf, local_conf)
     
     eq_(settings['mydict'], {'foo': "bar", 'baz': "abc", 'xyz': "mno"})
     # "twod.tuples" should have not been added:
     assert_false("twod.dictionaries" in settings)
Example #28
0
 def test_custom_nested_tuple(self):
     """Custom nested tuples should be converted."""
     items = ("foo;the bar;  baz", "bar ;foo", "baz")
     nested_items = (("foo", "the bar", "baz"), ("bar", "foo"), ("baz",))
     global_conf = {
         'debug': "yes",
         'twod.nested_tuples': ("my_nested_tuple", ),
         }
     local_conf = {'my_nested_tuple': "\n " + "\n    ".join(items)}
     
     settings = _convert_options(global_conf, local_conf)
     
     eq_(settings['my_nested_tuple'], nested_items)
     assert_false("twod.nested_tuples" in settings)
Example #29
0
 def test_non_if_empty_non_empty_settings(self):
     """Non-empty 'none if empty' settings are left as strings."""
     
     global_conf = {
         'debug': "yes",
         'twod.none_if_empty_settings': ("mynone", "mynonewithspace"),
         }
     local_conf = {'mynone': 'I am a string',
                   'mynonewithspace': ' I am a string '}
     settings = _convert_options(global_conf, local_conf)
     
     eq_(settings['mynone'], 'I am a string')
     eq_(settings['mynonewithspace'], 'I am a string')
     assert_false("twod.none_if_empty_settings" in settings)
Example #30
0
 def test_official_dictionaries(self):
     """Django's dictionary settings must be converted."""
     items = ("foo = bar", "baz=abc", " xyz = mno ")
     dict_items = {'foo': "bar", 'baz': "abc", 'xyz': "mno"}
     
     for setting_name in _DJANGO_DICTIONARIES:
         global_conf = {'debug': "yes"}
         local_conf = {setting_name: "\n " + "\n    ".join(items)}
         settings = _convert_options(global_conf, local_conf)
         
         eq_(settings[setting_name], dict_items,
             "%s must be a dict, but it is %r" % (setting_name,
                                                  settings[setting_name]),
             )
Example #31
0
 def test_official_booleans(self):
     """Django's boolean settings must be converted."""
     # We must exclude "DEBUG" because it's not supposed to be set in the
     # initial settings:
     booleans = _DJANGO_BOOLEANS - frozenset(["DEBUG"])
     
     for setting_name in booleans:
         global_conf = {'debug': "yes"}
         local_conf = {setting_name: "True"}
         settings = _convert_options(global_conf, local_conf)
         
         eq_(settings[setting_name],
             True,
             "%s must be a boolean, but it is %r" % (setting_name,
                                                     settings[setting_name]),
             )