-
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.
add get_cluster_relations to api client
looks like: ``` In [1]: from hypernode_api_python.client import HypernodeAPIPython In [2]: import os In [3]: client = HypernodeAPIPython(os.environ['MYSECRETAPITOKEN']) In [4]: client.get_cluster_relations("mytestappweb").json() Out[4]: {'parents': [{'id': 182, 'parent': 'mytestappdb', 'child': 'mytestappweb', 'relation_type': 'mysql', 'cluster_description': None}, {'id': 180, 'parent': 'mytestapp', 'child': 'mytestappweb', 'relation_type': 'loadbalancer', 'cluster_description': None}, {'id': 181, 'parent': 'mytestapp', 'child': 'mytestappweb', 'relation_type': 'nfs', 'cluster_description': None}], 'children': []} ```
- Loading branch information
Showing
2 changed files
with
57 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
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,28 @@ | ||
from unittest.mock import Mock | ||
|
||
from tests.testcase import TestCase | ||
from hypernode_api_python.client import ( | ||
HypernodeAPIPython, | ||
HYPERNODE_API_APP_CLUSTER_RELATIONS, | ||
) | ||
|
||
|
||
class TestGetClusterRelations(TestCase): | ||
def setUp(self): | ||
self.mock_request = Mock() | ||
self.client = HypernodeAPIPython(token="mytoken") | ||
self.client.requests = self.mock_request | ||
|
||
def test_calls_hypernode_api_cluster_relations_endpoint_with_correct_parameters( | ||
self, | ||
): | ||
self.client.get_cluster_relations("yourhypernodeappname") | ||
|
||
self.mock_request.assert_called_once_with( | ||
"GET", HYPERNODE_API_APP_CLUSTER_RELATIONS.format("yourhypernodeappname") | ||
) | ||
|
||
def test_returns_result_for_hypernode_api_cluster_relations(self): | ||
ret = self.client.get_cluster_relations("yourhypernodeappname") | ||
|
||
self.assertEqual(ret, self.mock_request.return_value) |