Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Ordering verify_quote method #1431

Merged
merged 1 commit into from
Mar 12, 2021
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
6 changes: 3 additions & 3 deletions SoftLayer/managers/ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ def verify_quote(self, quote_id, extra):
container = self.generate_order_template(quote_id, extra)
clean_container = {}

# There are a few fields that wil cause exceptions in the XML endpoing if you send in ''
# reservedCapacityId and hostId specifically. But we clean all just to be safe.
# There are a few fields that wil cause exceptions in the XML endpoint if you send in '',
# or None in Rest endpoint (e.g. reservedCapacityId, hostId). But we clean all just to be safe.
# This for some reason is only a problem on verify_quote.
for key in container.keys():
if container.get(key) != '':
if container.get(key):
clean_container[key] = container[key]

return self.client.call('SoftLayer_Billing_Order_Quote', 'verifyOrder', clean_container, id=quote_id)
Expand Down
6 changes: 4 additions & 2 deletions tests/managers/ordering_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,15 +713,17 @@ def test_clean_quote_verify(self):
'hostname': 'test1',
'domain': 'example.com'
}],
'testProperty': ''
'testPropertyEmpty': '',
'testPropertyNone': None
}
result = self.ordering.verify_quote(1234, extras)

self.assertEqual(result, fixtures.SoftLayer_Billing_Order_Quote.verifyOrder)
self.assert_called_with('SoftLayer_Billing_Order_Quote', 'verifyOrder')
call = self.calls('SoftLayer_Billing_Order_Quote', 'verifyOrder')[0]
order_container = call.args[0]
self.assertNotIn('testProperty', order_container)
self.assertNotIn('testPropertyEmpty', order_container)
self.assertNotIn('testPropertyNone', order_container)
self.assertNotIn('reservedCapacityId', order_container)

def test_get_item_capacity_core(self):
Expand Down