Skip to content

Commit

Permalink
Merge pull request #2188 from allmightyspiff/issues2130
Browse files Browse the repository at this point in the history
Fixed an issues with search command.
  • Loading branch information
allmightyspiff authored Oct 3, 2024
2 parents 967ef16 + 174f8c1 commit 7b7446b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
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',))

0 comments on commit 7b7446b

Please sign in to comment.