-
Notifications
You must be signed in to change notification settings - Fork 11
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
1 parent
540f627
commit fb04a7c
Showing
4 changed files
with
89 additions
and
0 deletions.
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,27 @@ | ||
from ipaddress import IPv4Address | ||
|
||
from unittest import TestCase | ||
from unittest.mock import MagicMock, patch | ||
|
||
from flask_seeder.generator import IPv4 | ||
|
||
|
||
class TestIPv4Generator(TestCase): | ||
def setUp(self): | ||
self.rnd_mock = MagicMock() | ||
# return value that will be used inside _string_from_ip_int function | ||
self.rnd_mock.randint.side_effect = [IPv4Address._ALL_ONES] | ||
|
||
|
||
def test_generate_mock_ipv4_with_default_values(self): | ||
self.generator = IPv4(rnd=self.rnd_mock) | ||
self.generator.generate() | ||
self.rnd_mock.randint.assert_called_once_with( | ||
0, | ||
IPv4Address._ALL_ONES | ||
) | ||
|
||
def test_generate_mock_ipv4_returns_a_string(self): | ||
self.generator = IPv4() | ||
result = self.generator.generate() | ||
self.assertEqual(type(result), str) |
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,27 @@ | ||
from ipaddress import IPv6Address | ||
|
||
from unittest import TestCase | ||
from unittest.mock import MagicMock, patch | ||
|
||
from flask_seeder.generator import IPv6 | ||
|
||
|
||
class TestIPv6Generator(TestCase): | ||
def setUp(self): | ||
self.rnd_mock = MagicMock() | ||
# return value that will be used inside _string_from_ip_int function | ||
self.rnd_mock.randint.side_effect = [IPv6Address._ALL_ONES] | ||
|
||
|
||
def test_generate_mock_ipv6_with_default_values(self): | ||
self.generator = IPv6(rnd=self.rnd_mock) | ||
self.generator.generate() | ||
self.rnd_mock.randint.assert_called_once_with( | ||
0, | ||
IPv6Address._ALL_ONES | ||
) | ||
|
||
def test_generate_mock_ipv6_returns_a_string(self): | ||
self.generator = IPv6() | ||
result = self.generator.generate() | ||
self.assertEqual(type(result), str) |