diff --git a/smash/web/tests/test_api.py b/smash/web/tests/test_api.py index 7772b9a2b8d3466a57fd66f921eae7a47f7968ec..fd6128ce816fea8c15d929f9993af1a56a654372 100644 --- a/smash/web/tests/test_api.py +++ b/smash/web/tests/test_api.py @@ -1,15 +1,12 @@ # coding=utf-8 -import datetime import json from django.contrib.auth.models import User -from django.test import TestCase from django.test import Client +from django.test import TestCase from django.urls import reverse -from web.models import Visit -from web.api_views import cities -from web.tests.functions import create_subject, create_worker, create_appointment_type +from web.tests.functions import create_subject, create_worker, create_appointment_type, create_location __author__ = 'Piotr Gawron' @@ -43,6 +40,24 @@ class TestApi(TestCase): self.assertTrue(city_name in cities) + def test_locations(self): + location_name = "some location" + + response = self.client.get(reverse('web.api.locations')) + self.assertEqual(response.status_code, 200) + + location = create_location(location_name) + + response = self.client.get(reverse('web.api.locations')) + appointment_types = json.loads(response.content)['locations'] + + found = False + for type in appointment_types: + if type['name'] == location_name: + found = True + + self.assertTrue(found) + def test_countries(self): country_name = "some country" @@ -130,7 +145,7 @@ class TestApi(TestCase): found = False for type in appointment_types: - if type['type']==type_name: + if type['type'] == type_name: found = True self.assertTrue(found)