-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from ByteInternet/add-fpm-status
add bin/get_fpm_status
- Loading branch information
Showing
5 changed files
with
112 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
command |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from unittest import TestCase | ||
from unittest.mock import Mock | ||
|
||
from hypernode_api_python.client import ( | ||
HypernodeAPIPython, | ||
HYPERNODE_API_FPM_STATUS_APP_ENDPOINT, | ||
) | ||
|
||
|
||
class TestGetFPMStatus(TestCase): | ||
def setUp(self): | ||
self.client = HypernodeAPIPython(token="my_token") | ||
self.mock_request = Mock() | ||
self.client.requests = self.mock_request | ||
self.app_name = "my_app" | ||
|
||
def test_get_fpm_status_endpoint_is_correct(self): | ||
self.assertEqual( | ||
"/v2/nats/{}/hypernode.show-fpm-status", | ||
HYPERNODE_API_FPM_STATUS_APP_ENDPOINT, | ||
) | ||
|
||
def test_calls_fpm_status_endpoint_properly(self): | ||
self.client.get_fpm_status(self.app_name) | ||
|
||
self.mock_request.assert_called_once_with( | ||
"POST", | ||
f"/v2/nats/{self.app_name}/hypernode.show-fpm-status", | ||
) | ||
|
||
def test_returns_fpm_status_data(self): | ||
response = Mock() | ||
response.status_code = 200 | ||
self.mock_request.return_value = response | ||
|
||
self.assertEqual( | ||
self.client.get_fpm_status(self.app_name), | ||
self.mock_request.return_value, | ||
) |
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,32 @@ | ||
from hypernode_api_python.commands import get_fpm_status | ||
from tests.testcase import TestCase | ||
|
||
|
||
class TestGetFPMStatus(TestCase): | ||
def setUp(self): | ||
self.print_response = self.set_up_patch( | ||
"hypernode_api_python.commands.print_response" | ||
) | ||
self.get_client = self.set_up_patch("hypernode_api_python.commands.get_client") | ||
self.client = self.get_client.return_value | ||
self.get_app_name = self.set_up_patch( | ||
"hypernode_api_python.commands.get_app_name" | ||
) | ||
self.get_app_name.return_value = "myappname" | ||
|
||
def test_get_fpm_status_gets_client(self): | ||
get_fpm_status([]) | ||
|
||
self.get_client.assert_called_once_with() | ||
|
||
def test_get_fpm_status_gets_fpm_status(self): | ||
get_fpm_status([]) | ||
|
||
self.client.get_fpm_status.assert_called_once_with("myappname") | ||
|
||
def test_get_fpm_status_prints_fpm_status(self): | ||
get_fpm_status([]) | ||
|
||
self.print_response.assert_called_once_with( | ||
self.client.get_fpm_status.return_value | ||
) |