Ejemplo n.º 1
0
 def test_configure_logging(self, basicconfig_mock):
     cfgparser = MagicMock()
     cfg = Configuration(cfgparser)
     cfgparser.get.side_effect = NoOptionError(None, None)
     cfg.configure_logging()
     cfgparser.get.assert_called_once_with('daemon', 'logging_config')
     basicconfig_mock.assert_called_once_with(
         stream=sys.stdout, format=ANY, level=ANY)
Ejemplo n.º 2
0
 def test_from_config_missing(self):
     cfgparser = MagicMock()
     cfg = Configuration(cfgparser)
     cfgparser.get.side_effect = NoOptionError('sec', 'one')
     ret = {}
     cfg._from_config(ret, 'sec', 'one')
     cfgparser.get.assert_called_with('sec', 'one')
     self.assertFalse('one' in ret)
Ejemplo n.º 3
0
 def get(self, section, option):
     if _section == section:
         if option == 'memcache_servers':
             if _srvs == 'error':
                 raise NoOptionError(option, section)
             return _srvs
         elif option == 'memcache_serialization_support':
             if _sers == 'error':
                 raise NoOptionError(option, section)
             return _sers
         elif option in ('memcache_max_connections', 'max_connections'):
             if _maxc == 'error':
                 raise NoOptionError(option, section)
             return _maxc
         else:
             raise NoOptionError(option, section)
     else:
         raise NoSectionError(option)
Ejemplo n.º 4
0
 def test_config_does_not_have_option(self):
     config = Mock()
     config.get.side_effect = NoOptionError('releases_service',
                                            'fedpkg.bodhi')
     six.assertRaisesRegex(
         self, rpkgError,
         r"Could not get release state for Fedora \(F30M\): "
         "No option 'releases_service' in section: 'fedpkg.bodhi'.",
         utils.get_fedora_release_state, config, 'fedpkg', 'F30M')
Ejemplo n.º 5
0
 def test_get_pidfile(self):
     cfgparser = MagicMock()
     cfg = Configuration(cfgparser)
     cfgparser.get.side_effect = ['/var/run/test',
                                  NoOptionError('daemon', 'pidfile')]
     self.assertEqual('/var/run/test', cfg.get_pidfile())
     cfgparser.get.assert_called_with('daemon', 'pidfile')
     self.assertEqual(None, cfg.get_pidfile())
     cfgparser.get.assert_called_with('daemon', 'pidfile')
Ejemplo n.º 6
0
 def test_get_rlimits(self):
     cfgparser = MagicMock()
     cfg = Configuration(cfgparser)
     cfgparser.getint.side_effect = [65535,
                                     NoOptionError('daemon', 'max_fd')]
     self.assertEqual([(resource.RLIMIT_NOFILE, (65535, 65535))],
                      list(cfg.get_rlimits()))
     cfgparser.getint.assert_called_with('daemon', 'max_fd')
     self.assertEqual([], list(cfg.get_rlimits()))
     cfgparser.getint.assert_called_with('daemon', 'max_fd')
Ejemplo n.º 7
0
 def test_configure_http(self, set_mock, reset_mock):
     cfgparser = MagicMock()
     cfg = Configuration(cfgparser)
     cfgparser.sections.return_value = ['one', 'http:test']
     cfgparser.get.side_effect = ['testhost',
                                  'testuser',
                                  'testpass',
                                  NoOptionError(None, None),
                                  NoOptionError(None, None)]
     cfgparser.getint.side_effect = [3306,
                                     NoOptionError(None, None)]
     cfgparser.getboolean.side_effect = [True]
     cfg.configure_http()
     reset_mock.assert_called_with()
     set_mock.assert_called_with('test',
                                 host='testhost',
                                 port=3306,
                                 user='******',
                                 password='******',
                                 ssl=True)
Ejemplo n.º 8
0
    def test_config_does_not_have_token(self):
        config = Mock()

        config.get.side_effect = NoOptionError('token', 'fedpkg.pagure')
        six.assertRaisesRegex(
            self, rpkgError,
            "Missing option 'token' in the section 'fedpkg.pagure'",
            utils.config_get_safely, config, 'fedpkg.pagure', 'token')

        config.get.side_effect = NoSectionError('fedpkg.pagure')
        six.assertRaisesRegex(self, rpkgError,
                              "Missing section 'fedpkg.pagure'",
                              utils.config_get_safely, config, 'fedpkg.pagure',
                              'token')
Ejemplo n.º 9
0
 def test_configure_amqp(self, set_mock):
     cfgparser = MagicMock()
     cfg = Configuration(cfgparser)
     cfgparser.sections.return_value = ['one', 'amqp']
     cfgparser.get.side_effect = [
         'testhost',
         'testuser',
         'testpass',
         NoOptionError('amqp', 'virtual_host')]
     cfgparser.getint.return_value = 5672
     cfgparser.getfloat.side_effect = [30.0, 10.0]
     cfg.configure_amqp()
     set_mock.assert_called_with(
         userid='testuser',
         password='******',
         host='testhost',
         port=5672,
         heartbeat=30.0,
         connect_timeout=10.0)
Ejemplo n.º 10
0
 def test_configure_mysql(self, set_mock, reset_mock):
     cfgparser = MagicMock()
     cfg = Configuration(cfgparser)
     cfgparser.sections.return_value = ['one', 'mysql:test']
     cfgparser.get.side_effect = [
         'testuser',
         'testpass',
         'testhost',
         'testdb',
         'testcharset',
         NoOptionError('mysql:test', 'unix_socket')]
     cfgparser.getint.side_effect = [3306, 10]
     cfg.configure_mysql()
     reset_mock.assert_called_with()
     set_mock.assert_called_with(
         'test',
         user='******',
         password='******',
         host='testhost',
         port=3306,
         database='testdb',
         charset='testcharset',
         connect_timeout=10)
Ejemplo n.º 11
0
 def config_read(section, key):
     assert section == 'morelia'
     if key == 'tags':
         raise NoOptionError(None, None)
     return ''