diff options
Diffstat (limited to 'openstackclient/tests')
3 files changed, 82 insertions, 0 deletions
diff --git a/openstackclient/tests/unit/image/v1/test_image.py b/openstackclient/tests/unit/image/v1/test_image.py index 8a83feb0..ae578d91 100644 --- a/openstackclient/tests/unit/image/v1/test_image.py +++ b/openstackclient/tests/unit/image/v1/test_image.py @@ -689,6 +689,32 @@ class TestImageSet(TestImage): ) self.assertIsNone(result) + def test_image_set_numeric_options_to_zero(self): + arglist = [ + '--min-disk', '0', + '--min-ram', '0', + self._image.name, + ] + verifylist = [ + ('min_disk', 0), + ('min_ram', 0), + ('image', self._image.name), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + + kwargs = { + 'min_disk': 0, + 'min_ram': 0, + } + # ImageManager.update(image, **kwargs) + self.images_mock.update.assert_called_with( + self._image.id, + **kwargs + ) + self.assertIsNone(result) + class TestImageShow(TestImage): diff --git a/openstackclient/tests/unit/image/v2/test_image.py b/openstackclient/tests/unit/image/v2/test_image.py index 429ddd28..383619ef 100644 --- a/openstackclient/tests/unit/image/v2/test_image.py +++ b/openstackclient/tests/unit/image/v2/test_image.py @@ -1313,6 +1313,32 @@ class TestImageSet(TestImage): exceptions.CommandError, self.cmd.take_action, parsed_args) + def test_image_set_numeric_options_to_zero(self): + arglist = [ + '--min-disk', '0', + '--min-ram', '0', + image_fakes.image_name, + ] + verifylist = [ + ('min_disk', 0), + ('min_ram', 0), + ('image', image_fakes.image_name), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + result = self.cmd.take_action(parsed_args) + + kwargs = { + 'min_disk': 0, + 'min_ram': 0, + } + # ImageManager.update(image, **kwargs) + self.images_mock.update.assert_called_with( + image_fakes.image_id, + **kwargs + ) + self.assertIsNone(result) + class TestImageShow(TestImage): diff --git a/openstackclient/tests/unit/network/v2/test_security_group_rule_network.py b/openstackclient/tests/unit/network/v2/test_security_group_rule_network.py index 36add8ca..fe6d3649 100644 --- a/openstackclient/tests/unit/network/v2/test_security_group_rule_network.py +++ b/openstackclient/tests/unit/network/v2/test_security_group_rule_network.py @@ -211,6 +211,36 @@ class TestCreateSecurityGroupRuleNetwork(TestSecurityGroupRuleNetwork): self.assertEqual(self.expected_columns, columns) self.assertEqual(self.expected_data, data) + def test_create_protocol_any(self): + self._setup_security_group_rule({ + 'protocol': None, + 'remote_ip_prefix': '10.0.2.0/24', + }) + arglist = [ + '--proto', 'any', + '--src-ip', self._security_group_rule.remote_ip_prefix, + self._security_group.id, + ] + verifylist = [ + ('proto', 'any'), + ('protocol', None), + ('src_ip', self._security_group_rule.remote_ip_prefix), + ('group', self._security_group.id), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + + columns, data = self.cmd.take_action(parsed_args) + + self.network.create_security_group_rule.assert_called_once_with(**{ + 'direction': self._security_group_rule.direction, + 'ethertype': self._security_group_rule.ether_type, + 'protocol': self._security_group_rule.protocol, + 'remote_ip_prefix': self._security_group_rule.remote_ip_prefix, + 'security_group_id': self._security_group.id, + }) + self.assertEqual(self.expected_columns, columns) + self.assertEqual(self.expected_data, data) + def test_create_remote_group(self): self._setup_security_group_rule({ 'port_range_max': 22, |
