summaryrefslogtreecommitdiffstats
path: root/mirrors/tests/test_mirrorlocations.py
blob: 92751669419754a1dae65261ceccb18c8ac37d39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)