def test_get_volume_filter_on_active(self, *args): set_module_args(dict( server='localhost', password='******', user='******', include='volume', filter='active:true' )) client = AnsibleF5Client( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, f5_product_name=self.spec.f5_product_name ) mm = ModuleManager(client) mm.exit_json = Mock(return_value=False) results = mm.exec_module() volumes = results['volumes'][0] assert results['changed'] is True assert 'images' not in results.keys() assert 'hotfixes' not in results.keys() assert len(results['volumes']) == 1 assert 'product' in volumes.keys() assert 'name' in volumes.keys() assert volumes['product'] == 'BIG-IP' assert volumes['name'] == 'HD1.1'
def test_get_all_facts_filter_on_version(self, *args): set_module_args( dict(server='localhost', password='******', user='******', include='all', filter='version:12.1.1')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) mm = ModuleManager(module=module) mm.exit_json = Mock(return_value=False) results = mm.exec_module() images = results['images'][0] volumes = results['volumes'][0] assert results['changed'] is True assert len(results['hotfixes']) == 0 assert len(results['images']) == 1 assert len(results['volumes']) == 1 assert 'product' in images.keys() assert 'name' in images.keys() assert 'product' in volumes.keys() assert 'name' in volumes.keys() assert images['product'] == 'BIG-IP' assert images['name'] == 'BIGIP-12.1.1.0.0.184.iso' assert volumes['product'] == 'BIG-IP' assert volumes['name'] == 'HD1.2'
def test_invalid_include_raises(self, *args): set_module_args( dict(server='localhost', password='******', user='******', include=['bar', 'foo'])) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) with pytest.raises(F5ModuleError) as err: msg = 'Include parameter may only be specified as one or more of the following: all, volume, image, hotfix' mm = ModuleManager(module=module) mm.exec_module() assert str(err.value) == msg
def test_invalid_filter_empty_value_raises(self, *args): set_module_args( dict(server='localhost', password='******', user='******', filter='name:')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) with pytest.raises(F5ModuleError) as err: msg = '"name:" is not a valid filter format. Filters must have key:value format' mm = ModuleManager(module=module) mm.exec_module() assert str(err.value) == msg
def test_invalid_filter_raises(self, *args): set_module_args( dict(server='localhost', password='******', user='******', filter='foo:bar')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) with pytest.raises(F5ModuleError) as err: msg = '"foo" is not a supported filter. Supported key values are: name, build, version, status, active' mm = ModuleManager(module=module) mm.exec_module() assert str(err.value) == msg
def test_invalid_filter_empty_key_raises(self, *args): set_module_args( dict(server='localhost', password='******', user='******', filter=':foobar')) client = AnsibleF5Client( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, f5_product_name=self.spec.f5_product_name) with pytest.raises(F5ModuleError) as err: msg = '":foobar" is not a valid filter format. Filters must have key:value format' mm = ModuleManager(client) mm.exec_module() assert str(err.value) == msg
def test_get_image_and_hotfixes_no_filter(self, *args): set_module_args( dict(server='localhost', password='******', user='******', include=['image', 'hotfix'])) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) mm = ModuleManager(module=module) mm.exit_json = Mock(return_value=False) results = mm.exec_module() assert results['changed'] is True assert len(results['images']) == 8 assert len(results['hotfixes']) == 5 assert 'volumes' not in results.keys()
def test_get_hotfixes_no_filter(self, *args): set_module_args( dict(server='localhost', password='******', user='******', include='hotfix')) client = AnsibleF5Client( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, f5_product_name=self.spec.f5_product_name) mm = ModuleManager(client) mm.exit_json = Mock(return_value=False) results = mm.exec_module() assert results['changed'] is True assert 'images' not in results.keys() assert 'volumes' not in results.keys() assert len(results['hotfixes']) == 5