Skip to content

Commit b24b26f

Browse files
committed
entrypoint check_payment_info / get_active_product
1 parent 67c8077 commit b24b26f

6 files changed

Lines changed: 114 additions & 2 deletions

File tree

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

bin/get_active_products

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
@@ -648,7 +648,6 @@ def get_current_product_for_app(self, app_name):
648648
"GET", HYPERNODE_API_PRODUCT_APP_DETAIL_ENDPOINT.format(app_name)
649649
)
650650

651-
# TODO: add entrypoint for this method in bin/ and commands.py
652651
def check_payment_information_for_app(self, app_name):
653652
"""
654653
Get the payment information that is currently configured for this Hypernode
@@ -666,7 +665,6 @@ def check_payment_information_for_app(self, app_name):
666665
"GET", HYPERNODE_API_APP_CHECK_PAYMENT_INFORMATION.format(app_name)
667666
)
668667

669-
# TODO: add entrypoint for this method in bin/ and commands.py
670668
def get_active_products(self):
671669
"""
672670
Retrieve the list of products that are currently available. You can

hypernode_api_python/commands.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,3 +508,48 @@ def get_current_product_for_app(args=None):
508508
client = get_client()
509509
app_name = get_app_name()
510510
print_response(client.get_current_product_for_app(app_name))
511+
512+
513+
def check_payment_information_for_app(args=None):
514+
parser = ArgumentParser(
515+
description="""
516+
Shows the payment information for the specified app.
517+
518+
Example:
519+
$ ./bin/check_payment_information_for_app
520+
{
521+
"has_valid_vat_number": true,
522+
"has_valid_payment_method": true
523+
}
524+
""",
525+
formatter_class=RawTextHelpFormatter,
526+
)
527+
parser.parse_args(args=args)
528+
client = get_client()
529+
app_name = get_app_name()
530+
print_response(client.check_payment_information_for_app(app_name))
531+
532+
533+
def get_active_products(args=None):
534+
parser = ArgumentParser(
535+
description="""
536+
Lists all available products.
537+
538+
Example:
539+
$ ./bin/get_active_products
540+
[
541+
{
542+
"code": "JACKAL_S_202301",
543+
"name": "Jackal S",
544+
"backups_enabled": true,
545+
"is_development": false,
546+
...
547+
},
548+
...
549+
]
550+
""",
551+
formatter_class=RawTextHelpFormatter,
552+
)
553+
parser.parse_args(args=args)
554+
client = get_client()
555+
print_response(client.get_active_products())
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from hypernode_api_python.commands import check_payment_information_for_app
2+
from tests.testcase import TestCase
3+
4+
5+
class TestCheckPaymentInformationForApp(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_check_payment_information_for_app_gets_client(self):
18+
check_payment_information_for_app([])
19+
20+
self.get_client.assert_called_once_with()
21+
22+
def test_check_payment_information_for_app_gets_app_name(self):
23+
check_payment_information_for_app([])
24+
25+
self.get_app_name.assert_called_once_with()
26+
27+
def test_check_payment_information_for_app_gets_current_product_for_app(self):
28+
check_payment_information_for_app([])
29+
30+
self.client.check_payment_information_for_app.assert_called_once_with(
31+
"myappname"
32+
)
33+
34+
def test_check_payment_information_for_app_prints_current_product_for_app(self):
35+
check_payment_information_for_app([])
36+
37+
self.print_response.assert_called_once_with(
38+
self.client.check_payment_information_for_app.return_value
39+
)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from hypernode_api_python.commands import get_active_products
2+
from tests.testcase import TestCase
3+
4+
5+
class TestGetActiveProducts(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+
13+
def test_get_active_products_gets_client(self):
14+
get_active_products([])
15+
16+
self.get_client.assert_called_once_with()
17+
18+
def test_get_active_products_gets_active_products(self):
19+
get_active_products([])
20+
21+
self.client.get_active_products.assert_called_once_with()
22+
23+
def test_get_active_products_prints_active_products(self):
24+
get_active_products([])
25+
26+
self.print_response.assert_called_once_with(
27+
self.client.get_active_products.return_value
28+
)

0 commit comments

Comments
 (0)