|
17 | 17 | PowerConfigPolynomialNotFoundException |
18 | 18 | ) |
19 | 19 |
|
| 20 | +def test_not_loaded(): |
| 21 | + pwrcfg = RsPowerConfig() |
| 22 | + assert False == pwrcfg.is_loaded() |
| 23 | + |
20 | 24 | def test_invalid_power_config_filepath(): |
21 | 25 | with pytest.raises(PowerConfigFileNotFoundException): |
22 | | - RsPowerConfig(filepath='abc.json') |
| 26 | + RsPowerConfig().load('abc.json') |
23 | 27 |
|
24 | 28 | def test_invalid_json_content(): |
25 | 29 | with pytest.raises(PowerConfigParsingException): |
26 | | - RsPowerConfig(filepath='tests/data/invalid_power_config.json') |
| 30 | + RsPowerConfig().load('tests/data/invalid_power_config.json') |
27 | 31 |
|
28 | 32 | def test_invalid_json_ref(): |
29 | 33 | with pytest.raises(PowerConfigParsingException): |
30 | | - RsPowerConfig(filepath='tests/data/invalid_json_ref_power_config.json') |
| 34 | + RsPowerConfig().load('tests/data/invalid_json_ref_power_config.json') |
31 | 35 |
|
32 | 36 | def test_invalid_power_config_schema(): |
33 | 37 | with pytest.raises(PowerConfigSchemaValidationException): |
34 | | - RsPowerConfig(filepath='tests/data/invalid_schema_power_config.json') |
| 38 | + RsPowerConfig().load('tests/data/invalid_schema_power_config.json') |
35 | 39 |
|
36 | 40 | def test_get_coeff_with_not_exist_component(): |
37 | | - pwrcfg = RsPowerConfig(filepath='tests/data/power_config.json') |
| 41 | + pwrcfg = RsPowerConfig() |
| 42 | + pwrcfg.load('tests/data/power_config.json') |
38 | 43 | with pytest.raises(PowerConfigComponentNotFoundException): |
39 | 44 | pwrcfg.get_coeff(ElementType.FABRIC_LE, "TEST1") |
40 | 45 |
|
41 | 46 | def test_get_coeff_with_not_exist_coeff(): |
42 | | - pwrcfg = RsPowerConfig(filepath='tests/data/power_config.json') |
| 47 | + pwrcfg = RsPowerConfig() |
| 48 | + pwrcfg.load('tests/data/power_config.json') |
43 | 49 | with pytest.raises(PowerConfigCoeffNotFoundException): |
44 | 50 | pwrcfg.get_coeff(ElementType.DSP, "ABC") |
45 | 51 |
|
46 | 52 | def test_get_coeff(): |
47 | | - pwrcfg = RsPowerConfig(filepath='tests/data/power_config.json') |
| 53 | + pwrcfg = RsPowerConfig() |
| 54 | + pwrcfg.load('tests/data/power_config.json') |
48 | 55 | assert 0.1234 == pwrcfg.get_coeff(ElementType.DSP, "TEST1") |
49 | 56 |
|
50 | 57 | def test_get_polynomial_coeff_with_not_exist_component(): |
51 | | - pwrcfg = RsPowerConfig(filepath='tests/data/power_config.json') |
| 58 | + pwrcfg = RsPowerConfig() |
| 59 | + pwrcfg.load('tests/data/power_config.json') |
52 | 60 | with pytest.raises(PowerConfigStaticComponentNotFoundException): |
53 | 61 | pwrcfg.get_polynomial_coeff(ElementType.NOC, ScenarioType.TYPICAL) |
54 | 62 |
|
55 | 63 | def test_get_polynomial_coeff_with_not_exist_scenario(): |
56 | | - pwrcfg = RsPowerConfig(filepath='tests/data/power_config.json') |
| 64 | + pwrcfg = RsPowerConfig() |
| 65 | + pwrcfg.load('tests/data/power_config.json') |
57 | 66 | with pytest.raises(PowerConfigPolynomialNotFoundException): |
58 | 67 | pwrcfg.get_polynomial_coeff(ElementType.CLB, ScenarioType.WORSE) |
59 | 68 |
|
60 | 69 | def test_get_polynomial_coeff(): |
61 | | - pwrcfg = RsPowerConfig(filepath='tests/data/power_config.json') |
| 70 | + pwrcfg = RsPowerConfig() |
| 71 | + result = pwrcfg.load('tests/data/power_config.json') |
62 | 72 | polynomials = pwrcfg.get_polynomial_coeff(ElementType.CLB, ScenarioType.TYPICAL) |
63 | 73 | assert 1 == len(polynomials) |
| 74 | + assert True == result |
| 75 | + assert True == pwrcfg.is_loaded() |
64 | 76 | assert 5 == polynomials[0].length |
65 | 77 | assert 1.25 == polynomials[0].factor |
66 | 78 | assert [0.1, 0.2, 0.3, 0.4, 0.5] == polynomials[0].coeffs |
0 commit comments