Skip to content

Commit 93c4036

Browse files
committed
Adding unittests
1 parent a3f2c58 commit 93c4036

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

SoftLayer/CLI/order/place_quote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def cli(env, package_keyname, location, preset, name, send_email, complex_type,
4747
Example:
4848
# Place quote a VSI with 4 CPU, 16 GB RAM, 100 GB SAN disk,
4949
# Ubuntu 16.04, and 1 Gbps public & private uplink in dal13
50-
slcli order place-quote --name " My quote name" --send-email CLOUD_SERVER DALLAS13 \\
50+
slcli order place-quote --name "foobar" --send-email CLOUD_SERVER DALLAS13 \\
5151
GUEST_CORES_4 \\
5252
RAM_16_GB \\
5353
REBOOT_REMOTE_CONSOLE \\

tests/CLI/modules/order_tests.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,35 @@ def test_place(self):
114114
'status': 'APPROVED'},
115115
json.loads(result.output))
116116

117+
def test_place_quote(self):
118+
order_date = '2018-04-04 07:39:20'
119+
expiration_date = '2018-05-04 07:39:20'
120+
quote_name = 'foobar'
121+
order = {'orderDate': order_date,
122+
'quote': {
123+
'id': 1234,
124+
'name': quote_name,
125+
'expirationDate': expiration_date,
126+
'status': 'PENDING'
127+
}}
128+
place_quote_mock = self.set_mock('SoftLayer_Product_Order', 'placeQuote')
129+
items_mock = self.set_mock('SoftLayer_Product_Package', 'getItems')
130+
131+
place_quote_mock.return_value = order
132+
items_mock.return_value = self._get_order_items()
133+
134+
result = self.run_command(['order', 'place-quote', '--name', 'foobar', 'package', 'DALLAS13',
135+
'ITEM1', '--complex-type', 'SoftLayer_Container_Product_Order_Thing'])
136+
137+
self.assert_no_fail(result)
138+
self.assert_called_with('SoftLayer_Product_Order', 'placeQuote')
139+
self.assertEqual({'id': 1234,
140+
'name': quote_name,
141+
'created': order_date,
142+
'expires': expiration_date,
143+
'status': 'PENDING'},
144+
json.loads(result.output))
145+
117146
def test_verify_hourly(self):
118147
order_date = '2017-04-04 07:39:20'
119148
order = {'orderId': 1234, 'orderDate': order_date,

tests/managers/ordering_tests.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,33 @@ def test_place_order(self):
431431
extras=extras, quantity=quantity)
432432
self.assertEqual(ord_mock.return_value, order)
433433

434+
def test_place_quote(self):
435+
ord_mock = self.set_mock('SoftLayer_Product_Order', 'placeQuote')
436+
ord_mock.return_value = {'id': 1234}
437+
pkg = 'PACKAGE_KEYNAME'
438+
location = 'DALLAS13'
439+
items = ['ITEM1', 'ITEM2']
440+
hourly = False
441+
preset_keyname = 'PRESET'
442+
complex_type = 'Complex_Type'
443+
extras = {'foo': 'bar'}
444+
quantity = 1
445+
name = 'wombat'
446+
send_email = True
447+
448+
with mock.patch.object(self.ordering, 'generate_order') as gen_mock:
449+
gen_mock.return_value = {'order': {}}
450+
451+
order = self.ordering.place_quote(pkg, location, items, preset_keyname=preset_keyname,
452+
complex_type=complex_type, extras=extras, quantity=quantity,
453+
quote_name=name, send_email=send_email)
454+
455+
gen_mock.assert_called_once_with(pkg, location, items, hourly=hourly,
456+
preset_keyname=preset_keyname,
457+
complex_type=complex_type,
458+
extras=extras, quantity=quantity)
459+
self.assertEqual(ord_mock.return_value, order)
460+
434461
def test_locations(self):
435462
locations = self.ordering.package_locations('BARE_METAL_CPU')
436463
self.assertEqual('WASHINGTON07', locations[0]['keyname'])

0 commit comments

Comments
 (0)