From 174f8c1f2e1280b6c9b1aeecfeb5383bcb0de2c9 Mon Sep 17 00:00:00 2001 From: Christopher Gallo Date: Wed, 2 Oct 2024 17:11:46 -0500 Subject: [PATCH] Fixed an issues with search command. Fixed #2130 --- SoftLayer/CLI/search.py | 5 +++-- tests/CLI/modules/search_tests.py | 13 ++++++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/SoftLayer/CLI/search.py b/SoftLayer/CLI/search.py index 23329ce51..84a79ff6e 100644 --- a/SoftLayer/CLI/search.py +++ b/SoftLayer/CLI/search.py @@ -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] diff --git a/tests/CLI/modules/search_tests.py b/tests/CLI/modules/search_tests.py index c14ce6b84..1b2540779 100644 --- a/tests/CLI/modules/search_tests.py +++ b/tests/CLI/modules/search_tests.py @@ -1,6 +1,6 @@ """ - SoftLayer.tests.CLI.modules.find_tests - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + SoftLayer.tests.CLI.modules.search_tests + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :license: MIT, see LICENSE for more details. """ @@ -8,16 +8,23 @@ 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',))