def test_create_selfip(self, *args): set_module_args(dict( name='foo', description='my description', timer_policy='timer1', port_misuse_policy='misuse1', partition='Common', state='present', password='******', server='localhost', user='******' )) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.exists = Mock(side_effect=[False, True]) mm.create_on_device = Mock(return_value=True) mm.module_provisioned = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True