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