summaryrefslogtreecommitdiffstats
path: root/tests/unit/ansible_library/plugins/action/calculate_test.py
blob: b053a4b90408eb9a271532026c39cd3de704ea55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
##############################################################################
# Copyright (c) 2017 ZTE Corp and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

import pytest

from qtip.ansible_library.plugins.action import calculate


def test_calc_metric(metric_spec, metrics, metric_baseline, metric_result):
    assert calculate.calc_metric(metric_spec,
                                 metrics['ssl_rsa'],
                                 metric_baseline) == metric_result


def test_calc_section(section_spec, metrics, section_baseline, section_result):
    assert calculate.calc_section(section_spec,
                                  metrics,
                                  section_baseline) == section_result


def test_calc_qpi(qpi_spec, metrics, qpi_baseline, qpi_result, section_spec, info):
    section_spec['score'] = 1.0
    assert calculate.calc_qpi(qpi_spec,
                              metrics,
                              info, qpi_baseline) == qpi_result


@pytest.mark.parametrize('metrics, baseline, expected', [
    (['612376.96k'], '612376.96k', 1)
])
def test_calc_score(metrics, baseline, expected):
    assert calculate.calc_score(metrics, baseline) == expected