Sort cloud regions in a stable way

* All comes first
* Then US regions
* Then all other regions alphabetically
This commit is contained in:
Matthew Jones
2018-03-13 15:29:45 -04:00
parent dcae4f65b5
commit acde2520d0
3 changed files with 21 additions and 5 deletions

View File

@@ -174,3 +174,11 @@ def test_get_custom_venv_choices():
with TemporaryDirectory(dir=settings.BASE_VENV_PATH) as temp_dir:
os.makedirs(os.path.join(temp_dir, 'bin', 'activate'))
assert common.get_custom_venv_choices() == [os.path.join(temp_dir, '')]
def test_region_sorting():
s = [('Huey', 'China1'),
('Dewey', 'UK1'),
('Lewie', 'US1'),
('All', 'All')]
assert [x[1] for x in sorted(s, key=common.region_sorting)] == ['All', 'US1', 'China1', 'UK1']