예제 #1
0
    def test_loads_defaults(self, get_appsettings):
        """Test that defaults are loaded."""
        c = config.BodhiConfig()

        c.load_config({'session.secret': 'secret', 'authtkt.secret': 'secret'})

        assert c['top_testers_timeframe'] == 7
예제 #2
0
    def test_valid_config(self):
        """A valid config should not raise Exceptions."""
        c = config.BodhiConfig()
        c.load_config({'session.secret': 'secret', 'authtkt.secret': 'secret'})

        # This should not raise an Exception
        c._validate()
예제 #3
0
    def test_koji_settings_are_strs(self):
        """
        Ensure that the koji related settings are strings.

        This test ensures that #1624[0] stays fixed.

        [0] https://github.com/fedora-infra/bodhi/issues/1624
        """
        c = config.BodhiConfig()
        c.load_config()
        # Let's set all of these to unicodes, and we'll assert that they get turned into strs.
        c['koji_hub'] = 'http://example.com/kojihub'
        c['krb_ccache'] = '/tmp/krb5cc_%{uid}'
        c['krb_keytab'] = '/etc/krb5.bodhi.keytab'
        c['krb_principal'] = 'bodhi/[email protected]'

        # This should not raise an Exception, but it should convert the above to strs.
        c._validate()

        for k in ('koji_hub', 'krb_ccache', 'krb_keytab', 'krb_principal'):
            assert type(c[k]) == str
        # And the values should match what we did above.
        assert c['koji_hub'] == 'http://example.com/kojihub'
        assert c['krb_ccache'] == '/tmp/krb5cc_%{uid}'
        assert c['krb_keytab'] == '/etc/krb5.bodhi.keytab'
        assert c['krb_principal'] == 'bodhi/[email protected]'
예제 #4
0
    def test_with_settings(self, get_appsettings):
        """Test with the optional settings parameter."""
        c = config.BodhiConfig()

        c.load_config({'wiki_url': 'test', 'session.secret': 'secret', 'authtkt.secret': 'secret'})

        assert c['wiki_url'] == 'test'
        assert get_appsettings.call_count == 0
예제 #5
0
    def test_dogpile_expire_is_int(self):
        """The dogpile.cache.expiration_time setting should be an int."""
        c = config.BodhiConfig()
        c.load_config()
        c['dogpile.cache.expiration_time'] = '3600'

        c._validate()

        assert isinstance(c['dogpile.cache.expiration_time'], int)
        assert c['dogpile.cache.expiration_time'] == 3600
예제 #6
0
    def test_marks_loaded(self, mock_appsettings):
        c = config.BodhiConfig()
        mock_appsettings.return_value = {'password': '******', 'session.secret': 'ssshhhhh',
                                         'authtkt.secret': 'keepitsafe'}

        c.load_config()

        mock_appsettings.assert_called_once_with('/some/config.ini')
        assert ('password', 'hunter2') in c.items()
        assert c.loaded
예제 #7
0
    def test_composer_paths_not_checked_for_existing(self):
        """We don't want compose specific paths to be checked for existence."""
        c = config.BodhiConfig()
        c.load_config()
        for s in ('pungi.cmd', 'compose_dir', 'compose_stage_dir'):
            c[s] = '/does/not/exist'

            # This should not raise an Exception.
            c._validate()

            assert c[s] == '/does/not/exist'
예제 #8
0
    def test_validates(self, get_appsettings):
        """Test that the config is validated."""
        c = config.BodhiConfig()

        with pytest.raises(ValueError) as exc:
            c.load_config({'authtkt.secure': 'not a bool', 'session.secret': 'secret',
                           'authtkt.secret': 'secret'})

        assert (str(exc.value) == (
            'Invalid config values were set: \n\tauthtkt.secure: "not a bool" cannot be '
            'interpreted as a boolean value.'))
예제 #9
0
파일: test_config.py 프로젝트: jlebon/bodhi
    def test_validates(self, get_appsettings):
        """Test that the config is validated."""
        c = config.BodhiConfig()

        with self.assertRaises(ValueError) as exc:
            c.load_config({'fedmsg_enabled': 'not a bool', 'session.secret': 'secret',
                           'authtkt.secret': 'secret'})

        self.assertEqual(
            str(exc.exception),
            ('Invalid config values were set: \n\tfedmsg_enabled: "not a bool" cannot be '
             'interpreted as a boolean value.'))
예제 #10
0
 def setup_method(self):
     self.config = config.BodhiConfig()
     self.config.load_config = mock.Mock()
     self.config['password'] = '******'
예제 #11
0
    def test_load_defaults(self):
        c = config.BodhiConfig()

        c._load_defaults()

        assert c == {'one': 'default'}
예제 #12
0
    def test_load_defaults(self):
        c = config.BodhiConfig()

        c._load_defaults()

        self.assertEqual(c, {'one': 'default'})