Beispiel #1
0
    def test_json_endpoint(self):
        response = self.client.get('/mirrors/status/json/')
        self.assertEqual(response.status_code, 200)
        data = response.json()
        self.assertEqual(data['urls'], [])

        mirror_url = create_mirror_url()

        # Verify that the cache works
        response = self.client.get('/mirrors/status/json/')
        self.assertEqual(response.status_code, 200)
        data = response.json()

        # Disables the cache_function's cache
        with self.settings(CACHES={
                'default': {
                    'BACKEND': 'django.core.cache.backends.dummy.DummyCache'
                }
        }):
            response = self.client.get('/mirrors/status/json/')
            self.assertEqual(response.status_code, 200)
            data = response.json()

            self.assertEqual(len(data['urls']), 1)
            mirror = data['urls'][0]
            self.assertEqual(mirror['url'], mirror_url.url)

        mirror_url.delete()
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
    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 = response.json()
        self.assertNotEqual(data['urls'], [])
Beispiel #5
0
    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 = response.json()
        self.assertNotEqual(data['urls'], [])
Beispiel #6
0
    def test_mirrorlist_all_https(self):
        # First test that without any https mirrors, we get a 404.
        response = self.client.get('/mirrorlist/all/https/')
        self.assertEqual(response.status_code, 404)

        # Now, after adding an HTTPS mirror, we expect to succeed.
        https_mirror_url = create_mirror_url(name='https_mirror',
                                             protocol='https',
                                             url='https://wikipedia.org')
        response = self.client.get('/mirrorlist/all/https/')
        self.assertEqual(response.status_code, 200)
        https_mirror_url.delete()
Beispiel #7
0
    def test_mirrorlist_all_https(self):
        # First test that without any https mirrors, we get a 404.
        response = self.client.get('/mirrorlist/all/https/')
        self.assertEqual(response.status_code, 404)

        # Now, after adding an HTTPS mirror, we expect to succeed.
        https_mirror_url = create_mirror_url(
            name='https_mirror',
            protocol='https',
            url='https://wikipedia.org')
        response = self.client.get('/mirrorlist/all/https/')
        self.assertEqual(response.status_code, 200)
        https_mirror_url.delete()
Beispiel #8
0
    def test_mirrorlist_filter(self):
        jp_mirror_url = create_mirror_url(name='jp_mirror',
                                          country='JP',
                                          protocol='https',
                                          url='https://wikipedia.jp')

        # First test that we correctly see the above mirror.
        response = self.client.get('/mirrorlist/?country=JP&protocol=https')
        self.assertEqual(response.status_code, 200)
        self.assertIn(jp_mirror_url.hostname, response.content)

        # Now confirm that the US mirror did not show up.
        self.assertNotIn(self.mirror_url.hostname, response.content)

        jp_mirror_url.delete()
Beispiel #9
0
    def test_mirrorlist_filter(self):
        jp_mirror_url = create_mirror_url(
            name='jp_mirror',
            country='JP',
            protocol='https',
            url='https://wikipedia.jp')

        # First test that we correctly see the above mirror.
        response = self.client.get('/mirrorlist/?country=JP&protocol=https')
        self.assertEqual(response.status_code, 200)
        self.assertIn(jp_mirror_url.hostname, response.content.decode())

        # Now confirm that the US mirror did not show up.
        self.assertNotIn(self.mirror_url.hostname, response.content.decode())

        jp_mirror_url.delete()
Beispiel #10
0
    def test_json_tier(self):
        response = self.client.get('/mirrors/status/tier/99/json/')
        self.assertEqual(response.status_code, 404)

        response = self.client.get('/mirrors/status/tier/1/json/')
        self.assertEqual(response.status_code, 200)
        data = response.json()
        self.assertEqual(data['urls'], [])

        mirror_url = create_mirror_url()

        # Disables the cache_function's cache
        with self.settings(CACHES={'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}}):
            response = self.client.get('/mirrors/status/json/')
            self.assertEqual(response.status_code, 200)
            data = response.json()
            self.assertNotEqual(data['urls'], [])

        mirror_url.delete()
Beispiel #11
0
    def test_json_endpoint(self):
        # Disables the cache_function's cache
        with self.settings(CACHES={'default': {'BACKEND': 'django.core.cache.backends.dummy.DummyCache'}}):
            response = self.client.get('/mirrors/status/json/')
            self.assertEqual(response.status_code, 200)
            data = response.json()
            self.assertEqual(data['urls'], [])

            mirror_url = create_mirror_url()

            response = self.client.get('/mirrors/status/json/')
            self.assertEqual(response.status_code, 200)
            data = response.json()

            self.assertEqual(len(data['urls']), 1)
            mirror = data['urls'][0]
            self.assertEqual(mirror['url'], mirror_url.url)

        mirror_url.delete()
Beispiel #12
0
    def test_json_tier(self):
        response = self.client.get('/mirrors/status/tier/99/json/')
        self.assertEqual(response.status_code, 404)

        response = self.client.get('/mirrors/status/tier/1/json/')
        self.assertEqual(response.status_code, 200)
        data = response.json()
        self.assertEqual(data['urls'], [])

        mirror_url = create_mirror_url()

        # Disables the cache_function's cache
        with self.settings(CACHES={
                'default': {
                    'BACKEND': 'django.core.cache.backends.dummy.DummyCache'
                }
        }):
            response = self.client.get('/mirrors/status/json/')
            self.assertEqual(response.status_code, 200)
            data = response.json()
            self.assertNotEqual(data['urls'], [])

        mirror_url.delete()
 def setUp(self):
     self.mirror_url = create_mirror_url()
Beispiel #14
0
 def setUp(self):
     self.mirror_url = create_mirror_url()
Beispiel #15
0
    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)
Beispiel #16
0
    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)