-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Tests for the netmask generator""" | ||
|
||
import re | ||
import unittest | ||
|
||
from fauxfactory import gen_netmask, VALID_NETMASKS | ||
|
||
|
||
NETMASK_REGEX = re.compile( | ||
'((255.){3}(0|128|192|224|240|248|252|254))|' | ||
'((255.){2}(0|128|192|224|240|248|252|254).0)|' | ||
'(255.(0|128|192|224|240|248|252|254)(.0){2})|' | ||
'((128|192|224|240|248|252|254)(.0){3})' | ||
) | ||
|
||
|
||
class NetmaskTestCase(unittest.TestCase): | ||
"""Tests for ``gen_netmask`` generator.""" | ||
|
||
def test_gen_netmask(self): | ||
"""Test if gen_netmask generates valid values""" | ||
result = gen_netmask() | ||
self.assertEqual(len(result.split('.')), 4) | ||
self.assertIsNotNone(NETMASK_REGEX.match(result)) | ||
|
||
def test_valid_netmasks(self): | ||
"""Test if VALID_NETMASKS constant have valid netmask values""" | ||
for netmask in VALID_NETMASKS: | ||
print netmask | ||
self.assertIsNotNone(NETMASK_REGEX.match(netmask)) |