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

Fixed an issues with search command. #2188

Merged
merged 1 commit into from
Oct 3, 2024
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: 3 additions & 2 deletions SoftLayer/CLI/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ def cli(env, query, types, advanced):
slcli -vvv search _objectType:SoftLayer_Hardware hostname:testibm --advanced
"""

# Before any Search operation
# Checks to make sure we have at least 1 query.
def check_opt(list_opt=None):
check = False
for input_ in list_opt:
if input_ is True:
if input_:
check = True
break

return check

list_opt = [query, types, advanced]
Expand Down
13 changes: 10 additions & 3 deletions tests/CLI/modules/search_tests.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
"""
SoftLayer.tests.CLI.modules.find_tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SoftLayer.tests.CLI.modules.search_tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:license: MIT, see LICENSE for more details.
"""

from SoftLayer import testing


class FindTests(testing.TestCase):
class SearchTests(testing.TestCase):

def test_find(self):
result = self.run_command(['search', '--types'])
self.assert_called_with("SoftLayer_Search", "getObjectTypes")
self.assert_no_fail(result)

def test_find_advanced(self):
result = self.run_command(['search', 'hardware', '--advanced'])
self.assert_called_with("SoftLayer_Search", "advancedSearch", args=('hardware',))
self.assert_no_fail(result)

def test_no_options(self):
result = self.run_command(['search'])
self.assertEqual(result.exit_code, 2)

def test_find_single_item(self):
result = self.run_command(['search', 'test.com'])
self.assert_no_fail(result)
self.assert_called_with("SoftLayer_Search", "search", args=('test.com',))
Loading