File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99HYPERNODE_API_APP_DETAIL_WITH_ADDONS_ENDPOINT = "/v2/app/{}/with_addons?destroyed=false"
1010HYPERNODE_API_APP_EAV_DESCRIPTION_ENDPOINT = "/v2/app/eav_descriptions/"
1111HYPERNODE_API_APP_FLAVOR_ENDPOINT = "/v2/app/{}/flavor/"
12+ HYPERNODE_API_APP_BRANCHER_ENDPOINT = "/v2/app/{}/brancher/"
1213HYPERNODE_API_APP_NEXT_BEST_PLAN_ENDPOINT = "/v2/app/{}/next_best_plan/"
1314HYPERNODE_API_APP_PRODUCT_LIST_ENDPOINT = "/v2/product/app/{}/"
1415HYPERNODE_API_APP_XGRADE_CHECK_ENDPOINT = "/v2/app/xgrade/{}/check/{}/"
@@ -628,3 +629,16 @@ def order_hypernode(self, data):
628629 :return obj response: The request response object
629630 """
630631 return self .requests ("POST" , HYPERNODE_API_APP_ORDER_ENDPOINT , data = data )
632+
633+ def create_brancher (self , app_name , data ):
634+ """
635+ Create a new branch (server replica) of your Hypernode.
636+
637+ :param str app_name: The name of the Hypernode to create the branch from
638+ :param dict data: Data regarding the branch to be created. An example could be:
639+ {'clear': 'mysql'}.
640+ :return obj response: The request response object
641+ """
642+ return self .requests (
643+ "POST" , HYPERNODE_API_APP_BRANCHER_ENDPOINT .format (app_name ), data = data
644+ )
Original file line number Diff line number Diff line change 1+ from unittest import TestCase
2+ from unittest .mock import Mock
3+
4+ from hypernode_api_python .client import (
5+ HYPERNODE_API_APP_BRANCHER_ENDPOINT ,
6+ HypernodeAPIPython ,
7+ )
8+
9+
10+ class TestCreateBrancher (TestCase ):
11+ def setUp (self ):
12+ self .client = HypernodeAPIPython (token = "my_token" )
13+ self .mock_request = Mock ()
14+ self .client .requests = self .mock_request
15+ self .app_name = "my_app"
16+
17+ def test_brancher_endpoint_is_correct (self ):
18+ self .assertEqual ("/v2/app/{}/brancher/" , HYPERNODE_API_APP_BRANCHER_ENDPOINT )
19+
20+ def test_calls_create_brancher_endpoint_properly (self ):
21+ data = {"clear_services" : ["mysql" ]}
22+ self .client .create_brancher (self .app_name , data )
23+
24+ self .mock_request .assert_called_once_with (
25+ "POST" , f"/v2/app/{ self .app_name } /brancher/" , data = data
26+ )
27+
28+ def test_returns_create_brancher_data (self ):
29+ response = Mock ()
30+ response .status_code = 200
31+ self .mock_request .return_value = response
32+
33+ self .assertEqual (
34+ self .client .create_brancher (self .app_name , {}),
35+ self .mock_request .return_value ,
36+ )
You can’t perform that action at this time.
0 commit comments