forked from softlayer/softlayer-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcustom_types_tests.py
More file actions
31 lines (24 loc) · 1.1 KB
/
custom_types_tests.py
File metadata and controls
31 lines (24 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
SoftLayer.tests.CLI.custom_types_tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:license: MIT, see LICENSE for more details.
"""
import click
from SoftLayer.CLI.custom_types import NetworkParamType
from SoftLayer import testing
class CustomTypesTests(testing.TestCase):
def test_network_param_convert(self):
param = NetworkParamType()
(ip_address, cidr) = param.convert('10.0.0.0/24', None, None)
self.assertEqual(ip_address, '10.0.0.0')
self.assertEqual(cidr, 24)
def test_network_param_convert_fails(self):
param = NetworkParamType()
self.assertRaises(click.exceptions.BadParameter,
lambda: param.convert('10.0.0.0//24', None, None))
self.assertRaises(click.exceptions.BadParameter,
lambda: param.convert('10.0.0.0', None, None))
self.assertRaises(click.exceptions.BadParameter,
lambda: param.convert('what is it', None, None))
self.assertRaises(click.exceptions.BadParameter,
lambda: param.convert('10.0.0.0/hi', None, None))