def test_provision_one_module_default_level(self, *args): # Configure the arguments that would be sent to the Ansible module set_module_args( dict(module='gtm', provider=dict(server='localhost', password='******', user='******'))) # Configure the parameters that would be returned by querying the # remote device current = ModuleParameters(dict(module='gtm', level='none')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, mutually_exclusive=self.spec.mutually_exclusive) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.update_on_device = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) mm.reboot_device = Mock(return_value=True) mm.save_on_device = Mock(return_value=True) # this forced sleeping can cause these tests to take 15 # or more seconds to run. This is deliberate. mm._is_mprov_running_on_device = Mock( side_effect=[True, False, False, False, False]) results = mm.exec_module() assert results['changed'] is True assert results['level'] == 'nominal'
def test_provision_one_module_default_level(self, *args): # Configure the arguments that would be sent to the Ansible module set_module_args(dict( module='gtm', password='******', server='localhost', user='******' )) # Configure the parameters that would be returned by querying the # remote device current = Parameters( dict( module='gtm', level='none' ) ) 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.update_on_device = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) mm.reboot_device = Mock(return_value=True) mm.save_on_device = Mock(return_value=True) # this forced sleeping can cause these tests to take 15 # or more seconds to run. This is deliberate. mm._is_mprov_running_on_device = Mock(side_effect=[True, False, False, False, False]) results = mm.exec_module() assert results['changed'] is True assert results['level'] == 'nominal'