Skip to content

Commit 9444cdd

Browse files
committed
mirrors: tests: remove duplicate tests
1 parent bcc131c commit 9444cdd

File tree

2 files changed

+23
-53
lines changed

2 files changed

+23
-53
lines changed

mirrors/tests/test_mirrorurl.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
1-
from django.test import TestCase
1+
from mirrors.tests.conftest import HOSTNAME, URL
22

3-
from mirrors.tests import create_mirror_url
43

4+
def test_mirrorurl_address_families(mirrorurl):
5+
assert not mirrorurl.address_families() is None
56

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
99

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
1214

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()
1519

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()
2022

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
2528

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)

mirrors/tests/test_models.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,4 @@
1-
from mirrors.tests.conftest import NAME, HOSTNAME, PROTOCOL, URL
2-
3-
4-
def test_mirrorurl_address_families(mirrorurl):
5-
assert not mirrorurl.address_families() is None
6-
7-
def test_mirrorurl_hostname(mirrorurl):
8-
assert mirrorurl.hostname == HOSTNAME
9-
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
14-
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()
19-
20-
def test_mirrorurl_get_full_url(mirrorurl):
21-
assert 'mirrors/{}'.format(mirrorurl.mirror.name) in mirrorurl.get_full_url()
22-
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
28-
29-
def test_mirrorurl_repr(mirrorurl):
30-
assert URL in repr(mirrorurl)
1+
from mirrors.tests.conftest import NAME, HOSTNAME, PROTOCOL
312

323

334
def test_mirror_get_full_url(mirror):

0 commit comments

Comments
 (0)