|
1 |
| -from django.test import TestCase |
| 1 | +from mirrors.tests.conftest import HOSTNAME, URL |
2 | 2 |
|
3 |
| -from mirrors.tests import create_mirror_url |
4 | 3 |
|
| 4 | +def test_mirrorurl_address_families(mirrorurl): |
| 5 | + assert not mirrorurl.address_families() is None |
5 | 6 |
|
6 |
| -class MirrorUrlTest(TestCase): |
7 |
| - def setUp(self): |
8 |
| - self.mirror_url = create_mirror_url() |
| 7 | +def test_mirrorurl_hostname(mirrorurl): |
| 8 | + assert mirrorurl.hostname == HOSTNAME |
9 | 9 |
|
10 |
| - def testAddressFamilies(self): |
11 |
| - self.assertIsNotNone(self.mirror_url.address_families()) |
| 10 | +def test_mirrorurl_get_absolute_url(mirrorurl): |
| 11 | + absolute_url = mirrorurl.get_absolute_url() |
| 12 | + expected = '/mirrors/%s/%d/' % (mirrorurl.mirror.name, mirrorurl.pk) |
| 13 | + assert absolute_url == expected |
12 | 14 |
|
13 |
| - def testHostname(self): |
14 |
| - self.assertEqual(self.mirror_url.hostname, 'archlinux.org') |
| 15 | +def test_mirrorurl_overview(client, mirrorurl): |
| 16 | + response = client.get('/mirrors/') |
| 17 | + assert response.status_code == 200 |
| 18 | + assert mirrorurl.mirror.name in response.content.decode() |
15 | 19 |
|
16 |
| - def testGetAbsoluteUrl(self): |
17 |
| - absolute_url = self.mirror_url.get_absolute_url() |
18 |
| - expected = '/mirrors/%s/%d/' % (self.mirror_url.mirror.name, self.mirror_url.pk) |
19 |
| - self.assertEqual(absolute_url, expected) |
| 20 | +def test_mirrorurl_get_full_url(mirrorurl): |
| 21 | + assert 'mirrors/{}'.format(mirrorurl.mirror.name) in mirrorurl.get_full_url() |
20 | 22 |
|
21 |
| - def test_mirror_overview(self): |
22 |
| - response = self.client.get('/mirrors/') |
23 |
| - self.assertEqual(response.status_code, 200) |
24 |
| - self.assertIn(self.mirror_url.mirror.name, response.content.decode()) |
| 23 | +def test_mirror_url_clean(mirrorurl): |
| 24 | + mirrorurl.clean() |
| 25 | + # TOOD(jelle): this expects HOSTNAME to resolve, maybe mock |
| 26 | + assert mirrorurl.has_ipv4 == True |
| 27 | + assert mirrorurl.has_ipv6 == True |
25 | 28 |
|
26 |
| - def testClean(self): |
27 |
| - # TODO: add test for self.mirror_url.clean() |
28 |
| - pass |
29 |
| - |
30 |
| - def tearDown(self): |
31 |
| - self.mirror_url.delete() |
| 29 | +def test_mirrorurl_repr(mirrorurl): |
| 30 | + assert URL in repr(mirrorurl) |
0 commit comments