From 9bee990d9b9e82974e876af76e9cd9ad315b23cd Mon Sep 17 00:00:00 2001 From: rditlsc9 Date: Thu, 21 Feb 2019 15:08:32 -0600 Subject: [PATCH] bufix to parse geoserver input as ints instead of floats --- .../test_tethys_apps/test_cli/test_docker_commands.py | 7 ++++--- tethys_apps/cli/docker_commands.py | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/unit_tests/test_tethys_apps/test_cli/test_docker_commands.py b/tests/unit_tests/test_tethys_apps/test_cli/test_docker_commands.py index 8450a464e..2c8abbc50 100644 --- a/tests/unit_tests/test_tethys_apps/test_cli/test_docker_commands.py +++ b/tests/unit_tests/test_tethys_apps/test_cli/test_docker_commands.py @@ -798,16 +798,17 @@ def test_uih_get_valid_numeric_input_valid(self): self.mock_input.assert_called_with('prompt (max 10) [1]: ') def test_uih_get_valid_numeric_input_invalid(self): - self.mock_input.side_effect = ['five', '11', '10'] + self.mock_input.side_effect = ['five', '11', '10.0', '10'] num = cli_docker_commands.UserInputHelper.get_valid_numeric_input(prompt='prompt', min_val=1, max_val=10) self.assertEqual(num, 10) input_call_args = self.mock_input.call_args_list - self.assertEqual(3, len(input_call_args)) + self.assertEqual(4, len(input_call_args)) self.assertEqual('prompt (max 10) [1]: ', input_call_args[0][0][0]) - self.assertEqual('Please enter a number\nprompt (max 10) [1]: ', input_call_args[1][0][0]) + self.assertEqual('Please enter an integer number\nprompt (max 10) [1]: ', input_call_args[1][0][0]) self.assertEqual('Number must be between 1 and 10\nprompt (max 10) [1]: ', input_call_args[2][0][0]) + self.assertEqual('Please enter an integer number\nprompt (max 10) [1]: ', input_call_args[1][0][0]) def test_uih_get_valid_choice_input_default(self): self.mock_input.side_effect = [''] diff --git a/tethys_apps/cli/docker_commands.py b/tethys_apps/cli/docker_commands.py index 03c047cdb..9b2a1aa8f 100644 --- a/tethys_apps/cli/docker_commands.py +++ b/tethys_apps/cli/docker_commands.py @@ -380,7 +380,7 @@ def get_container_options(self, defaults): max_memory = int(environment['MAX_MEMORY']) environment['MIN_MEMORY'] = UserInputHelper.get_valid_numeric_input( - prompt='Maximum memory to allocate to each GeoServer instance in MB', + prompt='Minimum memory to allocate to each GeoServer instance in MB', max_val=max_memory, default=max_memory ) @@ -716,9 +716,9 @@ def get_valid_numeric_input(prompt, min_val=1, max_val=None, default=None): while True: value = input('{}{}'.format(pre_prompt, prompt)) or str(default) try: - value = float(value) + value = int(value) except ValueError: - pre_prompt = 'Please enter a number\n' + pre_prompt = 'Please enter an integer number\n' continue temp_max = max_val or value