-
-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathtest_mirrorrsync.py
More file actions
43 lines (32 loc) · 1.48 KB
/
test_mirrorrsync.py
File metadata and controls
43 lines (32 loc) · 1.48 KB
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
40
41
42
43
from django.test import TransactionTestCase
from mirrors.models import MirrorRsync, Mirror
TEST_IPV6 = "2a0b:4342:1a31:410::"
TEST_IPV6_MASK = "2a0b:4342:1a31:410::/64"
TEST_IPV4 = "8.8.8.8"
TEST_IPV4_MASK = "192.168.1.0/24"
class MirrorRsyncTest(TransactionTestCase):
def setUp(self):
self.mirror = Mirror.objects.create(name='rmirror',
admin_email='foo@bar.com')
def tearDown(self):
self.mirror.delete()
def test_ipv6(self):
mirrorrsync = MirrorRsync.objects.create(ip=TEST_IPV6, mirror=self.mirror)
self.assertEqual(str(mirrorrsync), TEST_IPV6)
mirrorrsync.delete()
def test_ipv6_mask(self):
mirrorsync = MirrorRsync.objects.create(ip=TEST_IPV6_MASK, mirror=self.mirror)
self.assertEqual(str(mirrorsync), TEST_IPV6_MASK)
mirrorsync.delete()
def test_ipv4(self):
mirrorrsync = MirrorRsync.objects.create(ip=TEST_IPV4, mirror=self.mirror)
self.assertEqual(str(mirrorrsync), TEST_IPV4)
mirrorrsync.delete()
def test_ipv4_mask(self):
mirrorrsync = MirrorRsync.objects.create(ip=TEST_IPV4_MASK, mirror=self.mirror)
self.assertEqual(str(mirrorrsync), TEST_IPV4_MASK)
mirrorrsync.delete()
def test_invalid(self):
with self.assertRaises(ValueError) as e:
MirrorRsync.objects.create(ip="8.8.8.8.8", mirror=self.mirror)
self.assertIn('does not appear to be an IPv4 or IPv6 address', str(e.exception))