Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion SoftLayer/CLI/order/place.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def cli(env, package_keyname, location, preset, verify, billing, complex_type,
manager = ordering.OrderingManager(env.client)

if extras:
extras = json.loads(extras)
try:
extras = json.loads(extras)
except ValueError as err:
raise exceptions.CLIAbort("There was an error when parsing the --extras value: {}".format(err))

args = (package_keyname, location, order_items)
kwargs = {'preset_keyname': preset,
Expand Down
6 changes: 5 additions & 1 deletion SoftLayer/CLI/order/place_quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import click

from SoftLayer.CLI import environment
from SoftLayer.CLI import exceptions
from SoftLayer.CLI import formatting
from SoftLayer.managers import ordering

Expand Down Expand Up @@ -68,7 +69,10 @@ def cli(env, package_keyname, location, preset, name, send_email, complex_type,
manager = ordering.OrderingManager(env.client)

if extras:
extras = json.loads(extras)
try:
extras = json.loads(extras)
except ValueError as err:
raise exceptions.CLIAbort("There was an error when parsing the --extras value: {}".format(err))

args = (package_keyname, location, order_items)
kwargs = {'preset_keyname': preset,
Expand Down
15 changes: 15 additions & 0 deletions tests/CLI/modules/order_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
import json

from SoftLayer.CLI import exceptions
from SoftLayer import testing


Expand Down Expand Up @@ -103,6 +104,13 @@ def test_place(self):
'status': 'APPROVED'},
json.loads(result.output))

def test_place_extras_parameter_fail(self):
result = self.run_command(['-y', 'order', 'place', 'package', 'DALLAS13', 'ITEM1',
'--extras', '{"device":['])

self.assertEqual(result.exit_code, 2)
self.assertIsInstance(result.exception, exceptions.CLIAbort)

def test_place_quote(self):
order_date = '2018-04-04 07:39:20'
expiration_date = '2018-05-04 07:39:20'
Expand Down Expand Up @@ -132,6 +140,13 @@ def test_place_quote(self):
'status': 'PENDING'},
json.loads(result.output))

def test_place_quote_extras_parameter_fail(self):
result = self.run_command(['-y', 'order', 'place-quote', 'package', 'DALLAS13', 'ITEM1',
'--extras', '{"device":['])

self.assertEqual(result.exit_code, 2)
self.assertIsInstance(result.exception, exceptions.CLIAbort)

def test_verify_hourly(self):
order_date = '2017-04-04 07:39:20'
order = {'orderId': 1234, 'orderDate': order_date,
Expand Down