Skip to content

Commit 67873e6

Browse files
committed
add ./bin/get_active_branchers
1 parent 43198c7 commit 67873e6

4 files changed

Lines changed: 61 additions & 2 deletions

File tree

bin/get_active_branchers

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
command

hypernode_api_python/client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,6 @@ def get_active_products(self):
732732
"""
733733
return self.requests("GET", HYPERNODE_API_PRODUCT_LIST_ENDPOINT)
734734

735-
# TODO: add entrypoint for this method in bin/ and commands.py
736735
def check_xgrade(self, app_name, product_code):
737736
"""
738737
Checks if the Hypernode 'is going to fit' on the new product. Retrieves some
@@ -802,7 +801,6 @@ def order_hypernode(self, data):
802801
"""
803802
return self.requests("POST", HYPERNODE_API_APP_ORDER_ENDPOINT, data=data)
804803

805-
# TODO: add entrypoint for this method in bin/ and commands.py
806804
def get_active_branchers(self, app_name):
807805
"""
808806
List all active brancher nodes of your Hypernode.

hypernode_api_python/commands.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,3 +618,26 @@ def xgrade(args=None):
618618
"The job to xgrade Hypernode '{}' to product '{}' "
619619
"has been posted".format(app_name, args.product_code)
620620
)
621+
622+
623+
def get_active_branchers(args=None):
624+
parser = ArgumentParser(
625+
description="""
626+
List all active branchers
627+
628+
Example:
629+
$ ./bin/get_active_branchers
630+
{
631+
"monthly_total_time": 0,
632+
"total_minutes_elapsed": 0,
633+
"actual_monthly_total_cost": 0,
634+
"monthly_total_cost": 0,
635+
"branchers": []
636+
}
637+
""",
638+
formatter_class=RawTextHelpFormatter,
639+
)
640+
parser.parse_args(args=args)
641+
client = get_client()
642+
app_name = get_app_name()
643+
print_response(client.get_active_branchers(app_name))
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from hypernode_api_python.commands import get_active_branchers
2+
from tests.testcase import TestCase
3+
4+
5+
class TestGetActiveBranchers(TestCase):
6+
def setUp(self):
7+
self.print_response = self.set_up_patch(
8+
"hypernode_api_python.commands.print_response"
9+
)
10+
self.get_client = self.set_up_patch("hypernode_api_python.commands.get_client")
11+
self.client = self.get_client.return_value
12+
self.get_app_name = self.set_up_patch(
13+
"hypernode_api_python.commands.get_app_name"
14+
)
15+
self.get_app_name.return_value = "myappname"
16+
17+
def test_get_active_branchers_gets_client(self):
18+
get_active_branchers([])
19+
20+
self.get_client.assert_called_once_with()
21+
22+
def test_get_active_branchers_gets_app_name(self):
23+
get_active_branchers([])
24+
25+
self.get_app_name.assert_called_once_with()
26+
27+
def test_get_active_branchers_gets_active_branchers(self):
28+
get_active_branchers([])
29+
30+
self.client.get_active_branchers.assert_called_once_with("myappname")
31+
32+
def test_get_active_branchers_prints_active_branchers(self):
33+
get_active_branchers([])
34+
35+
self.print_response.assert_called_once_with(
36+
self.client.get_active_branchers.return_value
37+
)

0 commit comments

Comments
 (0)