evorepo/mirrors/tests/test_mirrorlocations.py
jelle van der Waa f42f357fdf Mirror tests (#78)
* mirrors: Move tests to mirrors/tests

Move the tests to separate files in mirrors/tests and expand the model
tests with tests for the Mirror class.

* Add CheckLocation test

* mirrors: Add tests for template filters

Include tests for the filters used in the mirrors views.

* devel: Add tests for template filter in_group

Include a test for a simple case of the in_group filter.
2018-01-22 12:41:39 -05:00

21 lines
721 B
Python

import json
from django.test import TestCase
from mirrors.models import CheckLocation
class MirrorLocationsTest(TestCase):
def setUp(self):
self.checklocation = CheckLocation.objects.create(hostname='arch.org',
source_ip='8.8.8.8',
country='US')
def test_mirrorlocations_json(self):
response = self.client.get('/mirrors/locations/json/')
self.assertEqual(response.status_code, 200)
data = json.loads(response.content)
self.assertEqual(1, data['version'])
location = data['locations'][0]['country_code']
self.assertEqual('US', location)