def test_api_parameters(self): ntp = ['192.168.1.1', '192.168.1.2'] args = dict(servers=ntp, timezone='Arctic/Longyearbyen') p = Parameters(params=args) assert p.ntp_servers == ntp assert p.timezone == 'Arctic/Longyearbyen'
def test_update_ntp_servers_and_timezone(self, *args): ntp = ['10.1.1.1', '10.1.1.2'] set_module_args( dict(ntp_servers=ntp, timezone='Arctic/Longyearbyen', 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 assert results['timezone'] == 'Arctic/Longyearbyen'
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(load_fixture('load_ntp.json')) 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) # 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