Exemplo n.º 1
0
    def test_cast_failure_log(self):
        """``dockage`` '_get_qos_value' logs the error if unable to cast value"""
        self.qos_params['memory'] = '18m'

        output = dockage._get_qos_value(self.qos_params,
                                        value_name='memory',
                                        value_type='int',
                                        logger=self.fake_logger)

        self.assertTrue(self.fake_logger.error.called)
Exemplo n.º 2
0
    def test_cast_failure(self):
        """``dockage`` '_get_qos_value' returns None if unable to cast value"""
        self.qos_params['memory'] = '18m'

        output = dockage._get_qos_value(self.qos_params,
                                        value_name='memory',
                                        value_type='int',
                                        logger=self.fake_logger)
        expected = None

        self.assertEqual(output, expected)
Exemplo n.º 3
0
    def test_cast_int(self):
        """``dockage`` '_get_qos_value' can cast values to integers"""
        self.qos_params['device_read_iops'] = '9001'

        output = dockage._get_qos_value(self.qos_params,
                                        value_name='device_read_iops',
                                        value_type='int',
                                        logger=self.fake_logger)
        expected = 9001

        self.assertEqual(output, expected)
Exemplo n.º 4
0
    def test_cast_float(self):
        """``dockage`` '_get_qos_value' can cast values to floats"""
        self.qos_params['cpus'] = '1.8'

        output = dockage._get_qos_value(self.qos_params,
                                        value_name='cpus',
                                        value_type='float',
                                        logger=self.fake_logger)
        expected = 1.8

        self.assertEqual(output, expected)
Exemplo n.º 5
0
    def test_cast_string(self):
        """``dockage`` '_get_qos_value' can cast values to strings"""
        self.qos_params['memory'] = '1g'

        output = dockage._get_qos_value(self.qos_params,
                                        value_name='memory',
                                        value_type='string',
                                        logger=self.fake_logger)
        expected = '1g'

        self.assertEqual(output, expected)