Skip to content

Commit a3ad28b

Browse files
Merge pull request #1327 from caberos/issue1326
fix the ha option firewall add and implement unit test
2 parents 228ccc0 + fa8c483 commit a3ad28b

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

SoftLayer/CLI/firewall/add.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
type=click.Choice(['vs', 'vlan', 'server']),
1616
help='Firewall type',
1717
required=True)
18-
@click.option('--ha', '--high-availability',
18+
@click.option('-ha', '--high-availability',
1919
is_flag=True,
2020
help='High available firewall option')
2121
@environment.pass_env

SoftLayer/fixtures/SoftLayer_Product_Package.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@
833833
'itemCategory': {'categoryCode': 'Uplink Port Speeds'},
834834
'prices': [{'id': 1122,
835835
'hourlyRecurringFee': 0.0,
836+
'recurringFee': 0.0,
836837
'categories': [{'id': 26,
837838
'name': 'Uplink Port Speeds',
838839
'categoryCode': 'port_speed'}]}],
@@ -845,6 +846,7 @@
845846
'itemCategory': {'categoryCode': 'Uplink Port Speeds'},
846847
'prices': [{'id': 4477,
847848
'hourlyRecurringFee': 0.0,
849+
'recurringFee': 0.0,
848850
'categories': [{'id': 26,
849851
'name': 'Uplink Port Speeds',
850852
'categoryCode': 'port_speed'}]}],
@@ -857,6 +859,7 @@
857859
'itemCategory': {'categoryCode': 'RAM'},
858860
'prices': [{'id': 1133,
859861
'hourlyRecurringFee': 0.0,
862+
'recurringFee': 0.0,
860863
'categories': [{'id': 3,
861864
'name': 'RAM',
862865
'categoryCode': 'ram'}]}],
@@ -870,6 +873,7 @@
870873
'itemCategory': {'categoryCode': 'Computing Instance'},
871874
'prices': [{'id': 1007,
872875
'hourlyRecurringFee': 0.0,
876+
'recurringFee': 0.0,
873877
'categories': [{'id': 80,
874878
'name': 'Computing Instance',
875879
'categoryCode': 'guest_core'}]}],
@@ -884,6 +888,7 @@
884888
'prices': [{'id': 1144,
885889
'locationGroupId': None,
886890
'hourlyRecurringFee': 0.0,
891+
'recurringFee': 0.0,
887892
'categories': [{'id': 80,
888893
'name': 'Computing Instance',
889894
'categoryCode': 'guest_core'}]}],
@@ -898,6 +903,7 @@
898903
'prices': [{'id': 332211,
899904
'locationGroupId': 1,
900905
'hourlyRecurringFee': 0.0,
906+
'recurringFee': 0.0,
901907
'categories': [{'id': 80,
902908
'name': 'Computing Instance',
903909
'categoryCode': 'guest_core'}]}],
@@ -908,7 +914,7 @@
908914
'capacity': '1',
909915
'description': '1 GB iSCSI Storage',
910916
'itemCategory': {'categoryCode': 'iscsi'},
911-
'prices': [{'id': 2222, 'hourlyRecurringFee': 0.0}],
917+
'prices': [{'id': 2222, 'hourlyRecurringFee': 0.0, 'recurringFee': 0.0}],
912918
},
913919
{
914920
'id': 1121,
@@ -924,55 +930,55 @@
924930
'capacity': '4',
925931
'description': '4 Portable Public IP Addresses',
926932
'itemCategory': {'categoryCode': 'sov_sec_ip_addresses_pub'},
927-
'prices': [{'id': 4444, 'hourlyRecurringFee': 0.0}],
933+
'prices': [{'id': 4444, 'hourlyRecurringFee': 0.0, 'recurringFee': 0.0}],
928934
},
929935
{
930936
'id': 8880,
931937
'keyName': 'KeyName0199',
932938
'capacity': '8',
933939
'description': '8 Portable Public IP Addresses',
934940
'itemCategory': {'categoryCode': 'sov_sec_ip_addresses_pub'},
935-
'prices': [{'id': 8888, 'hourlyRecurringFee': 0.0}],
941+
'prices': [{'id': 8888, 'hourlyRecurringFee': 0.0, 'recurringFee': 0.0}],
936942
},
937943
{
938944
'id': 44400,
939945
'keyName': 'KeyName0155',
940946
'capacity': '4',
941947
'description': '4 Portable Private IP Addresses',
942948
'itemCategory': {'categoryCode': 'sov_sec_ip_addresses_priv'},
943-
'prices': [{'id': 44441, 'hourlyRecurringFee': 0.0}],
949+
'prices': [{'id': 44441, 'hourlyRecurringFee': 0.0, 'recurringFee': 0.0}],
944950
},
945951
{
946952
'id': 88800,
947953
'keyName': 'KeyName0144',
948954
'capacity': '8',
949955
'description': '8 Portable Private IP Addresses',
950956
'itemCategory': {'categoryCode': 'sov_sec_ip_addresses_priv'},
951-
'prices': [{'id': 88881, 'hourlyRecurringFee': 0.0}],
957+
'prices': [{'id': 88881, 'hourlyRecurringFee': 0.0, 'recurringFee': 0.0}],
952958
},
953959
{
954960
'id': 10,
955961
'keyName': 'KeyName0341',
956962
'capacity': '0',
957963
'description': 'Global IPv4',
958964
'itemCategory': {'categoryCode': 'global_ipv4'},
959-
'prices': [{'id': 11, 'hourlyRecurringFee': 0.0}],
965+
'prices': [{'id': 11, 'hourlyRecurringFee': 0.0, 'recurringFee': 0.0}],
960966
},
961967
{
962968
'id': 66464,
963969
'keyName': 'KeyName0211',
964970
'capacity': '64',
965971
'description': '/64 Block Portable Public IPv6 Addresses',
966972
'itemCategory': {'categoryCode': 'static_ipv6_addresses'},
967-
'prices': [{'id': 664641, 'hourlyRecurringFee': 0.0}],
973+
'prices': [{'id': 664641, 'hourlyRecurringFee': 0.0, 'recurringFee': 0.0}],
968974
},
969975
{
970976
'id': 610,
971977
'keyName': 'KeyName031',
972978
'capacity': '0',
973979
'description': 'Global IPv6',
974980
'itemCategory': {'categoryCode': 'global_ipv6'},
975-
'prices': [{'id': 611, 'hourlyRecurringFee': 0.0}],
981+
'prices': [{'id': 611, 'hourlyRecurringFee': 0.0, 'recurringFee': 0.0}],
976982
}]
977983

978984
getItemPricesISCSI = [

tests/CLI/modules/firewall_tests.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:license: MIT, see LICENSE for more details.
66
"""
77
import json
8+
from unittest import mock
89

910
from SoftLayer import testing
1011

@@ -28,3 +29,24 @@ def test_list_firewalls(self):
2829
'firewall id': 'server:1234',
2930
'server/vlan id': 1,
3031
'type': 'Server - standard'}])
32+
33+
@mock.patch('SoftLayer.CLI.formatting.confirm')
34+
def test_add_vs(self, confirm_mock):
35+
confirm_mock.return_value = True
36+
result = self.run_command(['firewall', 'add', '1000', '--firewall-type=vlan', '-ha'])
37+
self.assert_no_fail(result)
38+
self.assertIn("Firewall is being created!", result.output)
39+
40+
@mock.patch('SoftLayer.CLI.formatting.confirm')
41+
def test_add_vlan(self, confirm_mock):
42+
confirm_mock.return_value = True
43+
result = self.run_command(['firewall', 'add', '1000', '--firewall-type=vs'])
44+
self.assert_no_fail(result)
45+
self.assertIn("Firewall is being created!", result.output)
46+
47+
@mock.patch('SoftLayer.CLI.formatting.confirm')
48+
def test_add_server(self, confirm_mock):
49+
confirm_mock.return_value = True
50+
result = self.run_command(['firewall', 'add', '1000', '--firewall-type=server'])
51+
self.assert_no_fail(result)
52+
self.assertIn("Firewall is being created!", result.output)

0 commit comments

Comments
 (0)