This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/devicedetailstags
- Loading branch information
Showing
10 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2024 Cisco Systems, Inc. and its affiliates | ||
|
||
# mypy: disable-error-code="empty-body" | ||
|
||
from catalystwan.endpoints import APIEndpoints, get | ||
from catalystwan.models.monitoring.server_info import ServerInfoResponse | ||
|
||
|
||
class ServerInfo(APIEndpoints): | ||
@get("/server/info") | ||
def get_server_info(self) -> ServerInfoResponse: | ||
... |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2024 Cisco Systems, Inc. and its affiliates | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
|
||
class ServerInfoResponse(BaseModel): | ||
"""The response may contain an incorrect spelling "Achitecture".""" | ||
|
||
architecture: str = Field(..., alias="Achitecture") | ||
available_processors: int = Field( | ||
..., serialization_alias="Available processors", validation_alias="Available processors" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2022 Cisco Systems, Inc. and its affiliates | ||
|
||
import unittest | ||
from unittest.mock import MagicMock, patch | ||
|
||
from catalystwan.endpoints.monitoring.server_info import ServerInfo | ||
from catalystwan.models.monitoring.server_info import ServerInfoResponse | ||
|
||
|
||
class TestServerInfo(unittest.TestCase): | ||
def setUp(self) -> None: | ||
self.mock_server_info_data = { | ||
"Achitecture": "x86_64", | ||
"Available processors": 4, | ||
} # Note the spelling error | ||
|
||
@patch("catalystwan.session.ManagerSession") | ||
def test_get_server_info(self, mock_session): | ||
# Arrange | ||
# Create a MagicMock for the response that has a dataobj method | ||
mock_response = MagicMock() | ||
# Set up the mock response's dataobj method to return a ServerInfoResponse | ||
mock_response.dataobj.return_value = ServerInfoResponse(**self.mock_server_info_data) | ||
|
||
# Mock the request method of the ManagerSession to return the mock response | ||
mock_session_instance = mock_session.return_value | ||
mock_session_instance.request.return_value = mock_response | ||
|
||
server_info_api = ServerInfo(mock_session_instance) | ||
|
||
# Act | ||
response = server_info_api.get_server_info() | ||
|
||
# Assert | ||
self.assertIsInstance(response, ServerInfoResponse) | ||
self.assertEqual(response.architecture, self.mock_server_info_data["Achitecture"]) | ||
self.assertEqual( | ||
response.available_processors, | ||
self.mock_server_info_data["Available processors"], | ||
) | ||
self.assertEqual(response.architecture, "x86_64") | ||
self.assertEqual(response.available_processors, 4) | ||
|
||
# Ensure the request method was called | ||
mock_session_instance.request.assert_called_once() | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters