def test_create_external_incorrect_integer_data(self, *args): set_module_args(dict( name='foo', delete_data_group_file=False, internal=False, type='integer', records_src="{0}/data-group-string.txt".format(fixture_path), separator=':=', state='present', partition='Common', server='localhost', password='******', user='******' )) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, mutually_exclusive=self.spec.mutually_exclusive, ) # Override methods in the specific type of manager mm1 = ExternalManager(module=module, params=module.params) mm1.exists = Mock(side_effect=[False, True]) mm1.create_on_device = Mock(return_value=True) # Override methods to force specific logic in the module to happen mm0 = ModuleManager(module=module) mm0.get_manager = Mock(return_value=mm1) with pytest.raises(F5ModuleError) as ex: mm0.exec_module() assert "When specifying an 'integer' type, the value to the left of the separator must be a number." == str(ex.value)
def test_create_external_datagroup_type_string(self, *args): set_module_args(dict( name='foo', delete_data_group_file=False, internal=False, records_src="{0}/data-group-string.txt".format(fixture_path), separator=':=', state='present', partition='Common', provider=dict( server='localhost', password='******', user='******' ) )) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, mutually_exclusive=self.spec.mutually_exclusive, ) # Override methods in the specific type of manager mm1 = ExternalManager(module=module, params=module.params) mm1.exists = Mock(side_effect=[False, True]) mm1.create_on_device = Mock(return_value=True) # Override methods to force specific logic in the module to happen mm0 = ModuleManager(module=module) mm0.get_manager = Mock(return_value=mm1) results = mm0.exec_module() assert results['changed'] is True
def test_create_external_datagroup_type_string(self, *args): set_module_args(dict( name='foo', delete_data_group_file=False, internal=False, records_src="{0}/data-group-string.txt".format(fixture_path), separator=':=', state='present', partition='Common', server='localhost', password='******', user='******' )) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, mutually_exclusive=self.spec.mutually_exclusive, ) # Override methods in the specific type of manager mm1 = ExternalManager(module=module, params=module.params) mm1.exists = Mock(side_effect=[False, True]) mm1.create_on_device = Mock(return_value=True) # Override methods to force specific logic in the module to happen mm0 = ModuleManager(module=module) mm0.get_manager = Mock(return_value=mm1) results = mm0.exec_module() assert results['changed'] is True
def test_create_external_incorrect_integer_data(self, *args): set_module_args( dict(name='foo', delete_data_group_file=False, internal=False, type='integer', records_src="{0}/data-group-string.txt".format(fixture_path), separator=':=', state='present', partition='Common', provider=dict(server='localhost', password='******', user='******'))) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, mutually_exclusive=self.spec.mutually_exclusive, ) # Override methods in the specific type of manager mm1 = ExternalManager(module=module, params=module.params) mm1.exists = Mock(side_effect=[False, True]) mm1.create_on_device = Mock(return_value=True) # Override methods to force specific logic in the module to happen mm0 = ModuleManager(module=module) mm0.get_manager = Mock(return_value=mm1) with pytest.raises(F5ModuleError) as ex: mm0.exec_module() assert "When specifying an 'integer' type, the value to the left of the separator must be a number." == str( ex.value)