Skip to content

Commit

Permalink
Merge pull request #398 from sdc50/docker_bugfix
Browse files Browse the repository at this point in the history
release hotfix to parse geoserver input as ints instead of floats
  • Loading branch information
swainn authored Feb 22, 2019
2 parents f6bbd93 + 9bee990 commit b204397
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ['']
Expand Down
6 changes: 3 additions & 3 deletions tethys_apps/cli/docker_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b204397

Please sign in to comment.