Example #1
0
    def test_non_list_config(self):
        config = {}

        ret = load.validate(config)

        self.assertEqual(
            ret, (False, "Configuration for load beacon must be a list."))
Example #2
0
    def test_empty_config(self):
        config = [{}]

        ret = load.validate(config)

        self.assertEqual(ret, (False, 'Averages configuration is required'
                               ' for load beacon.'))
Example #3
0
def test_load_match():
    with patch("os.getloadavg", MagicMock(return_value=(1.82, 1.84, 1.56))):
        config = [{
            "averages": {
                "1m": [0.0, 2.0],
                "5m": [0.0, 1.5],
                "15m": [0.0, 1.0]
            },
            "emitatstartup": True,
            "onchangeonly": False,
        }]

        ret = load.validate(config)
        assert ret == (True, "Valid beacon configuration")

        _expected_return = [{"1m": 1.82, "5m": 1.84, "15m": 1.56}]
        ret = load.beacon(config)
        assert ret == _expected_return
Example #4
0
    def test_load_match(self):
        with patch('os.getloadavg',
                   MagicMock(return_value=(1.82, 1.84, 1.56))):
            config = [{
                'averages': {
                    '1m': [0.0, 2.0],
                    '5m': [0.0, 1.5],
                    '15m': [0.0, 1.0]
                }
            }]

            ret = load.validate(config)

            self.assertEqual(ret, (True, 'Valid beacon configuration'))

            _expected_return = [{'15m': 1.56, '1m': 1.82, '5m': 1.84}]
            ret = load.beacon(config)
            self.assertEqual(ret, _expected_return)
Example #5
0
def test_empty_config():
    config = [{}]

    ret = load.validate(config)
    assert ret == (False,
                   "Averages configuration is required for load beacon.")
Example #6
0
def test_non_list_config():
    config = {}

    ret = load.validate(config)
    assert ret == (False, "Configuration for load beacon must be a list.")