Wludzik, Jozef | 405c1e4 | 2021-01-28 16:24:27 +0100 | [diff] [blame] | 1 | import pytest |
| 2 | import redfish_requests |
| 3 | |
| 4 | |
| 5 | def pytest_addoption(parser): |
| 6 | parser.addoption('--host_addr', action='store', |
| 7 | default='https://localhost:4443') |
| 8 | parser.addoption('--username', action='store', default='root') |
| 9 | parser.addoption('--password', action='store', default='0penBmc') |
| 10 | parser.addoption('--metric_limit', action='store', default=200) |
| 11 | |
| 12 | |
| 13 | @pytest.fixture(scope='session') |
| 14 | def redfish(request): |
| 15 | host_addr = request.config.getoption('--host_addr') |
| 16 | username = request.config.getoption('--username') |
| 17 | password = request.config.getoption('--password') |
| 18 | return redfish_requests.RedfishRequest(host_addr, username, password) |
| 19 | |
| 20 | |
| 21 | @pytest.fixture(scope='session') |
| 22 | def telemetry(request, redfish): |
| 23 | metric_limit = request.config.getoption('--metric_limit') |
| 24 | return redfish_requests.TelemetryService(redfish, metric_limit) |
| 25 | |
| 26 | |
| 27 | @pytest.fixture(scope='function') |
| 28 | def report_definitions(redfish): |
| 29 | report_definitions = redfish_requests.ReportDef(redfish) |
| 30 | print('Cleaning reports before test') |
| 31 | for report in report_definitions.get_collection(): |
| 32 | report_definitions.delete_report(report) |
| 33 | yield report_definitions |
| 34 | print('Cleaning reports after test') |
| 35 | for report in report_definitions.get_collection(): |
| 36 | report_definitions.delete_report(report) |