Skip to content
Snippets Groups Projects
Commit b8e0d183 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

test for api get locations

parent 1074938a
No related branches found
No related tags found
1 merge request!34Performance of subject list
# 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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment