@@ -148,3 +148,59 @@ def test_returns_failed_validation_on_invalid_ipv6_cidr_address(
148
148
):
149
149
"""Test returns failed validation on invalid ipv6 CIDR address."""
150
150
assert isinstance (ipv6 (address , cidr = cidr , strict = strict , host_bit = host_bit ), ValidationError )
151
+
152
+
153
+ @pytest .mark .parametrize (
154
+ ("address" , "private" ),
155
+ [
156
+ ("10.1.1.1" , False ),
157
+ ("192.168.1.1" , False ),
158
+ ("169.254.1.1" , False ),
159
+ ("127.0.0.1" , False ),
160
+ ("0.0.0.0" , False ),
161
+ ],
162
+ )
163
+ def test_returns_failed_validation_on_private_ipv4_address (address : str , private : bool ):
164
+ """Test returns failed validation on invalid ipv4 CIDR address."""
165
+ assert isinstance (ipv4 (address , private = private ), ValidationError )
166
+
167
+
168
+ @pytest .mark .parametrize (
169
+ ("address" , "private" ),
170
+ [
171
+ ("10.1.1.1" , True ),
172
+ ("192.168.1.1" , True ),
173
+ ("169.254.1.1" , True ),
174
+ ("127.0.0.1" , True ),
175
+ ("0.0.0.0" , True ),
176
+ ],
177
+ )
178
+ def test_returns_valid_on_private_ipv4_address (address : str , private : bool ):
179
+ """Test returns failed validation on invalid ipv4 CIDR address."""
180
+ assert ipv4 (address , private = private )
181
+
182
+
183
+ @pytest .mark .parametrize (
184
+ ("address" , "private" ),
185
+ [
186
+ ("1.1.1.1" , True ),
187
+ ("192.169.1.1" , True ),
188
+ ("7.53.12.1" , True ),
189
+ ],
190
+ )
191
+ def test_returns_failed_validation_on_not_private_ipv4_address (address : str , private : bool ):
192
+ """Test returns failed validation on invalid ipv4 CIDR address."""
193
+ assert isinstance (ipv4 (address , private = private ), ValidationError )
194
+
195
+
196
+ @pytest .mark .parametrize (
197
+ ("address" , "private" ),
198
+ [
199
+ ("1.1.1.1" , False ),
200
+ ("192.169.1.1" , False ),
201
+ ("7.53.12.1" , False ),
202
+ ],
203
+ )
204
+ def test_returns_valid_on_private_ipv4_address (address : str , private : bool ):
205
+ """Test returns failed validation on invalid ipv4 CIDR address."""
206
+ assert ipv4 (address , private = private )
0 commit comments