|
| 1 | +# Copyright (c) 2024, Inria |
| 2 | +# Copyright (c) 2024, University of Lille |
| 3 | +# All rights reserved. |
| 4 | +# |
| 5 | +# Redistribution and use in source and binary forms, with or without |
| 6 | +# modification, are permitted provided that the following conditions are met: |
| 7 | +# |
| 8 | +# * Redistributions of source code must retain the above copyright notice, this |
| 9 | +# list of conditions and the following disclaimer. |
| 10 | +# |
| 11 | +# * Redistributions in binary form must reproduce the above copyright notice, |
| 12 | +# this list of conditions and the following disclaimer in the documentation |
| 13 | +# and/or other materials provided with the distribution. |
| 14 | +# |
| 15 | +# * Neither the name of the copyright holder nor the names of its |
| 16 | +# contributors may be used to endorse or promote products derived from |
| 17 | +# this software without specific prior written permission. |
| 18 | +# |
| 19 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 20 | +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 22 | +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 23 | +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 24 | +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 25 | +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 26 | +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 27 | +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | +import pytest |
| 30 | + |
| 31 | +from powerapi.report import PowerReport |
| 32 | +from tests.utils.report.power import gen_json_power_report |
| 33 | + |
| 34 | + |
| 35 | +@pytest.fixture |
| 36 | +def power_report_without_metadata() -> PowerReport: |
| 37 | + """ |
| 38 | + Generates a power_power |
| 39 | + """ |
| 40 | + json_input = gen_json_power_report(1)[0] |
| 41 | + report = PowerReport.from_json(json_input) |
| 42 | + |
| 43 | + return report |
| 44 | + |
| 45 | + |
| 46 | +@pytest.fixture |
| 47 | +def power_report_with_metadata(power_report_without_metadata) -> PowerReport: |
| 48 | + """ |
| 49 | + Generates a power_power |
| 50 | + """ |
| 51 | + power_report_without_metadata.metadata = {'k1': 'v1', |
| 52 | + 'k2': 'v2', |
| 53 | + 'k3': 333, |
| 54 | + 'k4': 'vv4'} |
| 55 | + |
| 56 | + return power_report_without_metadata |
| 57 | + |
| 58 | + |
| 59 | +@pytest.fixture |
| 60 | +def power_report_with_nested_metadata(power_report_without_metadata) -> PowerReport: |
| 61 | + """ |
| 62 | + Generates a power_power |
| 63 | + """ |
| 64 | + power_report_without_metadata.metadata = {'k1': {'k1_k1': 1}, |
| 65 | + 'k2': 'v2', |
| 66 | + 'k3': 333, |
| 67 | + 'k4': {'k4_k1': 'v1', |
| 68 | + 'k4_k2': {'k4_k2_k1': 'v2'} |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + return power_report_without_metadata |
0 commit comments