def test_update_ntp_servers(self, *args): ntp = ['10.1.1.1', '10.1.1.2'] set_module_args( dict(ntp_servers=ntp, server='localhost', user='******', password='******')) # Configure the parameters that would be returned by querying the # remote device current = Parameters(params=load_fixture('load_ntp.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, required_one_of=self.spec.required_one_of) 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) results = mm.exec_module() assert results['changed'] is True assert results['ntp_servers'] == ntp
def test_absent_timezone(self, *args): set_module_args( dict( timezone='', state='absent', provider=dict( server='localhost', password='******', user='******' ) ) ) # Configure the parameters that would be returned by querying the # remote device current = Parameters(params=load_fixture('load_ntp.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, required_one_of=self.spec.required_one_of ) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.absent_on_device = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) results = mm.exec_module() assert results['changed'] is False
def test_absent_ntp_servers(self, *args): ntp = [] set_module_args( dict(ntp_servers=ntp, timezone='America/Los_Angeles', server='localhost', user='******', password='******', state='absent')) # Configure the parameters that would be returned by querying the # remote device current = Parameters(params=load_fixture('load_ntp.json')) 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.absent_on_device = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) results = mm.exec_module() assert results['changed'] is True assert results['ntp_servers'] == ntp assert not hasattr(results, 'timezone')
def test_update_ntp_servers(self, *args): ntp = ['10.1.1.1', '10.1.1.2'] set_module_args( dict( ntp_servers=ntp, server='localhost', user='******', password='******' ) ) # Configure the parameters that would be returned by querying the # remote device current = Parameters(params=load_fixture('load_ntp.json')) 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) results = mm.exec_module() assert results['changed'] is True assert results['ntp_servers'] == ntp