Skip to content

Add slcli order quote-save #1451

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

Merged
merged 3 commits into from
Apr 6, 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
33 changes: 33 additions & 0 deletions SoftLayer/CLI/order/quote_save.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Save a quote"""
# :license: MIT, see LICENSE for more details.
import click

from SoftLayer.CLI import environment
from SoftLayer.CLI import formatting
from SoftLayer.managers import ordering
from SoftLayer.utils import clean_time


@click.command()
@click.argument('quote')
@environment.pass_env
def cli(env, quote):
"""Save a quote"""

manager = ordering.OrderingManager(env.client)
result = manager.save_quote(quote)

table = formatting.Table([
'Id', 'Name', 'Created', 'Modified', 'Status'
])
table.align['Name'] = 'l'

table.add_row([
result.get('id'),
result.get('name'),
clean_time(result.get('createDate')),
clean_time(result.get('modifyDate')),
result.get('status'),
])

env.fout(table)
1 change: 1 addition & 0 deletions SoftLayer/CLI/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
('order:place-quote', 'SoftLayer.CLI.order.place_quote:cli'),
('order:quote-list', 'SoftLayer.CLI.order.quote_list:cli'),
('order:quote-detail', 'SoftLayer.CLI.order.quote_detail:cli'),
('order:quote-save', 'SoftLayer.CLI.order.quote_save:cli'),
('order:quote', 'SoftLayer.CLI.order.quote:cli'),
('order:lookup', 'SoftLayer.CLI.order.lookup:cli'),

Expand Down
2 changes: 2 additions & 0 deletions SoftLayer/fixtures/SoftLayer_Billing_Order_Quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@
]
}
}

saveQuote = getObject
7 changes: 7 additions & 0 deletions SoftLayer/managers/ordering.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ def get_quote_details(self, quote_id):
quote = self.client['Billing_Order_Quote'].getObject(id=quote_id, mask=mask)
return quote

def save_quote(self, quote_id):
"""Save a quote.

:param quote_id: ID number of target quote
"""
return self.client['Billing_Order_Quote'].saveQuote(id=quote_id)

def get_order_container(self, quote_id):
"""Generate an order container from a quote object.

Expand Down
4 changes: 4 additions & 0 deletions docs/cli/ordering.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ Quotes
:prog: order quote-detail
:show-nested:

.. click:: SoftLayer.CLI.order.quote_save:cli
:prog: order quote-save
:show-nested:

.. click:: SoftLayer.CLI.order.place_quote:cli
:prog: order place-quote
:show-nested:
Expand Down
5 changes: 5 additions & 0 deletions tests/CLI/modules/order_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ def test_quote_detail(self):
self.assert_no_fail(result)
self.assert_called_with('SoftLayer_Billing_Order_Quote', 'getObject', identifier='12345')

def test_quote_save(self):
result = self.run_command(['order', 'quote-save', '12345'])
self.assert_no_fail(result)
self.assert_called_with('SoftLayer_Billing_Order_Quote', 'saveQuote', identifier='12345')

def test_quote_list(self):
result = self.run_command(['order', 'quote-list'])
self.assert_no_fail(result)
Expand Down
7 changes: 7 additions & 0 deletions tests/managers/ordering_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ def test_get_quote_details(self):
quote_fixture = quote_service.getObject(id=1234)
self.assertEqual(quote, quote_fixture)

def test_save_quote(self):
saved_quote = self.ordering.save_quote(1234)
quote_service = self.ordering.client['Billing_Order_Quote']
quote_fixture = quote_service.getObject(id=1234)
self.assertEqual(saved_quote, quote_fixture)
self.assert_called_with('SoftLayer_Billing_Order_Quote', 'saveQuote', identifier=1234)

def test_verify_quote(self):
extras = {
'hardware': [{
Expand Down