Added missing check for arguments in dhcp_options_exists.

This commit is contained in:
Omer Katz 2014-10-02 11:51:46 +03:00
parent b0f11e2e70
commit 02654ce0d4
2 changed files with 8 additions and 0 deletions

View File

@ -537,6 +537,9 @@ def dhcp_options_exists(dhcp_options_id=None, name=None, tags=None, region=None,
if not conn:
return False
if not dhcp_options_id and not name and not tags:
raise SaltInvocationError('At least on of the following must be specified: dhcp options id, name or tags.')
try:
filter_parameters = {'filters': {}}

View File

@ -567,6 +567,11 @@ class BotoVpcDHCPOptionsTestCase(BotoVpcTestCaseBase):
self.assertFalse(dhcp_options_exists_result)
@mock_ec2
def test_that_when_checking_if_dhcp_options_exists_but_providing_no_filters_the_dhcp_options_exists_method_raises_a_salt_invocation_error(self):
with self.assertRaisesRegexp(SaltInvocationError, 'At least on of the following must be specified: subnet id, name or tags.'):
boto_vpc.dhcp_options_exists(**conn_parameters)
@skipIf(NO_MOCK, NO_MOCK_REASON)
@skipIf(HAS_BOTO is False, 'The boto module must be installed.')