summaryrefslogtreecommitdiffstats
path: root/mirrors/tests/test_mirrors.py
blob: 9258ad7aac10c848bcba827ec6e0d6864afbc13b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import json

from django.test import TestCase

from mirrors.tests import create_mirror_url


class MirrorTest(TestCase):

    def test_details(self):
        response = self.client.get('/mirrors/nothing/')
        self.assertEqual(response.status_code, 404)

        mirror_url = create_mirror_url()
        url = mirror_url.mirror.get_absolute_url()

        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)

        # FIXME: request as mirror admin

    def test_details_json(self):
        response = self.client.get('/mirrors/nothing/json/')
        self.assertEqual(response.status_code, 404)

        mirror_url = create_mirror_url()
        url = mirror_url.mirror.get_absolute_url()

        response = self.client.get(url + 'json/')
        self.assertEqual(response.status_code, 200)
        data = json.loads(response.content)
        self.assertNotEqual(data['urls'], [])

    def test_url_details(self):
        mirror_url = create_mirror_url()
        url = mirror_url.mirror.get_absolute_url()

        response = self.client.get(url + '{}/'.format(mirror_url.id))
        self.assertEqual(response.status_code, 200)