File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 22
33DEFAULT_USER_AGENT = "hypernode-api-python"
44HYPERNODE_API_URL = "https://api.hypernode.com"
5+ HYPERNODE_API_ADDON_LIST_ENDPOINT = "/v2/addon/"
56HYPERNODE_API_ADDON_SLA_LIST_ENDPOINT = "/v2/addon/slas/"
67HYPERNODE_API_APP_CHECK_PAYMENT_INFORMATION = "/v2/app/{}/check-payment-information/"
78HYPERNODE_API_APP_CONFIGURATION_ENDPOINT = "/v2/configuration/"
@@ -272,6 +273,22 @@ def get_slas(self):
272273 """
273274return self .requests ("GET" , HYPERNODE_API_ADDON_SLA_LIST_ENDPOINT )
274275
276+ def get_sla (self , sla_code ):
277+ """
278+ List a specific SLA
279+ Example:
280+ > client.get_sla("sla-standard").json()
281+ >{'billing_period': 1,
282+ > 'billing_period_unit': 'month',
283+ > 'code': 'sla-standard',
284+ > 'id': 123,
285+ > 'name': 'SLA Standard',
286+ > 'price': 1234}
287+
288+ :return obj response: The request response object
289+ """
290+ return self .requests ("GET" , HYPERNODE_API_ADDON_LIST_ENDPOINT + sla_code + "/" )
291+
275292def get_available_backups_for_app (self , app_name ):
276293"""
277294 Lists the available backups for the specified app
Original file line number Diff line number Diff line change 1+ from unittest .mock import Mock
2+
3+ from tests .testcase import TestCase
4+ from hypernode_api_python .client import (
5+ HypernodeAPIPython ,
6+ HYPERNODE_API_ADDON_LIST_ENDPOINT ,
7+ )
8+
9+
10+ class TestGetSla (TestCase ):
11+ def setUp (self ):
12+ self .mock_request = Mock ()
13+ self .client = HypernodeAPIPython (token = "mytoken" )
14+ self .client .requests = self .mock_request
15+
16+ def test_calls_hypernode_api_endpoint_with_correct_parameters (self ):
17+ self .client .get_sla ("sla-standard" )
18+
19+ self .mock_request .assert_called_once_with (
20+ "GET" , HYPERNODE_API_ADDON_LIST_ENDPOINT + "sla-standard/"
21+ )
22+
23+ def test_returns_json_result (self ):
24+ ret = self .client .get_sla ("sla-standard" )
25+
26+ self .assertEqual (ret , self .mock_request .return_value )
You can’t perform that action at this time.
0 commit comments