Skip to content

Commit

Permalink
update zoneinfo endpoint to be a list of dicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanpetrello committed Feb 8, 2018
1 parent e982f6e commit c866d85
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion awx/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,10 @@ class ScheduleZoneInfo(APIView):

def get(self, request):
from dateutil.zoneinfo import get_zonefile_instance
return Response(sorted(get_zonefile_instance().zones.keys()))
return Response([
{'name': zone}
for zone in sorted(get_zonefile_instance().zones)
])


class LaunchConfigCredentialsBase(SubListAttachDetachAPIView):
Expand Down
7 changes: 7 additions & 0 deletions awx/main/tests/functional/api/test_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,10 @@ def test_dst_rollback_duplicates(post, admin_user):
'2030-11-03 02:30:00-05:00',
'2030-11-03 03:30:00-05:00',
]


@pytest.mark.django_db
def test_zoneinfo(get, admin_user):
url = reverse('api:schedule_zoneinfo')
r = get(url, admin_user, expect=200)
assert {'name': 'America/New_York'} in r.data
6 changes: 3 additions & 3 deletions docs/schedules.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ A list of _valid_ zone identifiers (which can vary by system) can be found at:
HTTP GET /api/v2/schedules/zoneinfo/

[
"Africa/Abidjan",
"Africa/Accra",
"Africa/Addis_Ababa",
{"name": "Africa/Abidjan"},
{"name": "Africa/Accra"},
{"name": "Africa/Addis_Ababa"},
...
]

Expand Down

0 comments on commit c866d85

Please sign in to comment.