File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ from django .test import TransactionTestCase
2
+
3
+ from mirrors .models import MirrorRsync , Mirror
4
+
5
+
6
+ TEST_IPV6 = "2a0b:4342:1a31:410::"
7
+ TEST_IPV4 = "8.8.8.8"
8
+
9
+ class MirrorRsyncTest (TransactionTestCase ):
10
+ def setUp (self ):
11
+ self .mirror = Mirror .objects .create (name = 'rmirror' ,
12
+
13
+
14
+ def tearDown (self ):
15
+ self .mirror .delete ()
16
+
17
+ def test_ipv6 (self ):
18
+ mirrorrsync = MirrorRsync .objects .create (ip = TEST_IPV6 , mirror = self .mirror )
19
+ self .assertEqual (str (mirrorrsync ), TEST_IPV6 )
20
+ mirrorrsync .delete ()
21
+
22
+ def test_ipv4 (self ):
23
+ mirrorrsync = MirrorRsync .objects .create (ip = TEST_IPV4 , mirror = self .mirror )
24
+ self .assertEqual (str (mirrorrsync ), TEST_IPV4 )
25
+ mirrorrsync .delete ()
26
+
27
+ def test_invalid (self ):
28
+ with self .assertRaises (ValueError ) as e :
29
+ MirrorRsync .objects .create (ip = "8.8.8.8.8" , mirror = self .mirror )
30
+ self .assertIn ('IPv4 Address with more than 4 bytes' , str (e .exception ))
You can’t perform that action at this time.
0 commit comments