mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-06 12:07:14 +00:00
Initial commit
This commit is contained in:
commit
aebc1b03fd
4861 changed files with 812621 additions and 0 deletions
31
tests/unit/modules/cloud/docker/test_docker_network.py
Normal file
31
tests/unit/modules/cloud/docker/test_docker_network.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
"""Unit tests for docker_network."""
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import pytest
|
||||
|
||||
from ansible_collections.community.general.plugins.modules.cloud.docker.docker_network import validate_cidr
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cidr,expected", [
|
||||
('192.168.0.1/16', 'ipv4'),
|
||||
('192.168.0.1/24', 'ipv4'),
|
||||
('192.168.0.1/32', 'ipv4'),
|
||||
('fdd1:ac8c:0557:7ce2::/64', 'ipv6'),
|
||||
('fdd1:ac8c:0557:7ce2::/128', 'ipv6'),
|
||||
])
|
||||
def test_validate_cidr_positives(cidr, expected):
|
||||
assert validate_cidr(cidr) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize("cidr", [
|
||||
'192.168.0.1',
|
||||
'192.168.0.1/34',
|
||||
'192.168.0.1/asd',
|
||||
'fdd1:ac8c:0557:7ce2::',
|
||||
])
|
||||
def test_validate_cidr_negatives(cidr):
|
||||
with pytest.raises(ValueError) as e:
|
||||
validate_cidr(cidr)
|
||||
assert '"{0}" is not a valid CIDR'.format(cidr) == str(e.value)
|
||||
Loading…
Add table
Add a link
Reference in a new issue