Skip to content

Commit 67c8077

Browse files
committed
implement bin/get_current_product_for_app
1 parent 91aaa9e commit 67c8077

4 files changed

Lines changed: 69 additions & 1 deletion

File tree

bin/get_current_product_for_app

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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,6 @@ def get_whitelist_rules(self, app_name, filter_data=None):
580580
"GET", HYPERNODE_API_WHITELIST_ENDPOINT.format(app_name), filter_data
581581
)
582582

583-
# TODO: add entrypoint for this method in bin/ and commands.py
584583
def get_current_product_for_app(self, app_name):
585584
"""
586585
Retrieve information about the product the specified App is currently on.

hypernode_api_python/commands.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,3 +477,34 @@ def get_whitelist_rules(args=None):
477477
client = get_client()
478478
app_name = get_app_name()
479479
print_response(client.get_whitelist_rules(app_name))
480+
481+
482+
def get_current_product_for_app(args=None):
483+
parser = ArgumentParser(
484+
description="""
485+
Gets the current product for the specified app.
486+
487+
Example:
488+
$ ./bin/get_current_product_for_app
489+
{
490+
"code": "FALCON_M_202203",
491+
"name": "Falcon M",
492+
"backups_enabled": true,
493+
"is_development": false,
494+
"varnish_supported": true,
495+
"supports_sla": true,
496+
"provider_flavors": [
497+
{
498+
"vcpus": 3,
499+
"ram_in_mb": 16384,
500+
...
501+
},
502+
...
503+
}
504+
""",
505+
formatter_class=RawTextHelpFormatter,
506+
)
507+
parser.parse_args(args=args)
508+
client = get_client()
509+
app_name = get_app_name()
510+
print_response(client.get_current_product_for_app(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_current_product_for_app
2+
from tests.testcase import TestCase
3+
4+
5+
class TestGetCurrentProductForApp(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_current_product_for_app_gets_client(self):
18+
get_current_product_for_app([])
19+
20+
self.get_client.assert_called_once_with()
21+
22+
def test_get_current_product_for_app_gets_app_name(self):
23+
get_current_product_for_app([])
24+
25+
self.get_app_name.assert_called_once_with()
26+
27+
def test_get_current_product_for_app_gets_current_product_for_app(self):
28+
get_current_product_for_app([])
29+
30+
self.client.get_current_product_for_app.assert_called_once_with("myappname")
31+
32+
def test_get_current_product_for_app_prints_current_product_for_app(self):
33+
get_current_product_for_app([])
34+
35+
self.print_response.assert_called_once_with(
36+
self.client.get_current_product_for_app.return_value
37+
)

0 commit comments

Comments
 (0)