Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jelle van der Waa
Archweb
Commits
2146c423
Commit
2146c423
authored
Feb 14, 2020
by
Jelle van der Waa
🚧
Browse files
mirrors: test the MirrorRsync model
parent
cc8996ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
mirrors/tests/test_mirrorrsync.py
0 → 100644
View file @
2146c423
from
django.test
import
TransactionTestCase
from
mirrors.models
import
MirrorRsync
,
Mirror
TEST_IPV6
=
"2a0b:4342:1a31:410::"
TEST_IPV4
=
"8.8.8.8"
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_ipv4
(
self
):
mirrorrsync
=
MirrorRsync
.
objects
.
create
(
ip
=
TEST_IPV4
,
mirror
=
self
.
mirror
)
self
.
assertEqual
(
str
(
mirrorrsync
),
TEST_IPV4
)
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
(
'IPv4 Address with more than 4 bytes'
,
str
(
e
.
exception
))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment