Initial commit

This commit is contained in:
Neill Cox 2023-09-11 20:22:22 +10:00
commit 1b51716d1b
72 changed files with 8204 additions and 0 deletions

79
tests/cli/test_chassis.py Normal file
View file

@ -0,0 +1,79 @@
"""Test for the cli componenets"""
# pylint: disable=redefined-outer-name, no-name-in-module, unused-import
import json
import pytest
import requests
import redfish_cli.cli
from redfish_cli import api
from redfish_cli.api import storage
from ..utils import get_test_json, MockResponse, MockRedfishResponse
from .test_cli import secrets
def test_chassis(capsys, monkeypatch, secrets):
"""Test the cli chassis command"""
def mock_get(*args, **kwargs):
# pylint: disable=unused-argument
mock_redfish = MockRedfishResponse()
mock_redfish.json_dict = get_test_json("cli_chassis.json")
return MockResponse(status_code=200, content=mock_redfish.text)
monkeypatch.setattr(requests, "get", mock_get)
args = redfish_cli.cli.parse_args(
[
"-s",
secrets["server"],
"-f",
"json",
"chassis",
"-p",
secrets["password"],
"-u",
secrets["username"],
]
)
redfish_cli.cli.chassis(args)
captured = capsys.readouterr()
result = json.loads(captured.out)
assert result["@odata.id"] == "/redfish/v1/Chassis/System.Embedded.1"
def test_get_chassis_details(capsys, monkeypatch):
"""Test the cli chassis-details command"""
_json = get_test_json("cli_chassis_details.json")
monkeypatch.setattr(
requests,
"get",
lambda *args, **kwargs: MockResponse(
content=json.dumps(_json), status_code=200
),
)
args = redfish_cli.cli.parse_args(
[
"-s",
"172.1.0.1",
"-f",
"json",
"chassis",
"--username",
"root",
"-p",
"password",
"show",
"-c",
"System.Embedded.1",
]
)
redfish_cli.cli.redfish(args=args)
# captured = capsys.readouterr()
result = json.loads(capsys.readouterr().out)
assert result["Name"] == "Computer System Chassis"