def test_wait_ssh_ready(self, *args): """ Wait till tenant accepts ssh connections. """ set_module_args(dict(name='defaultbip', state='ssh-ready')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) # Override methods to force specific logic in the module to happen mm = ModuleManager(module=module) mm.tenant_exists = Mock(side_effect=[True, True]) deployed_state = load_fixture('load_tenant_state_deployed.json') mm.read_tenant_from_device = Mock(return_value=deployed_state) # Simulate the first ssh connection attempt raises an SSHExecption # indicating ssh is not ready, followed by a second connection which # raises AuthenticationException, indicating ssh server is up. with patch.object(paramiko, 'SSHClient', autospec=True) as mock_ssh: mocked_client = MagicMock() attrs = { 'connect.side_effect': [ paramiko.ssh_exception.SSHException, paramiko.ssh_exception.AuthenticationException ] } mocked_client.configure_mock(**attrs) mock_ssh.return_value = mocked_client results = mm.exec_module() assert results['changed'] is False assert mm.tenant_exists.call_count == 2 assert mocked_client.connect.call_count == 2
def setUp(self): self.spec = ArgumentSpec() self.p1 = patch( 'ansible_collections.f5networks.f5_bigip.plugins.modules.velos_partition_interface.F5Client' ) self.m1 = self.p1.start() self.m1.return_value = MagicMock()
def setUp(self): self.spec = ArgumentSpec() self.p1 = patch( 'ansible_collections.f5networks.f5_bigip.plugins.modules.velos_tenant_image.F5Client' ) self.p2 = patch('time.sleep') self.p2.start() self.m1 = self.p1.start() self.m1.return_value = MagicMock()
def setUp(self): self.spec = ArgumentSpec() self.p1 = patch('time.sleep') self.p1.start() self.p2 = patch('ansible_collections.f5networks.f5_bigip.plugins.modules.bigip_sslo_service_tap.F5Client') self.m2 = self.p2.start() self.m2.return_value = MagicMock() self.p3 = patch('ansible_collections.f5networks.f5_bigip.plugins.modules.bigip_sslo_service_tap.sslo_version') self.m3 = self.p3.start() self.m3.return_value = '8.0'
def setUp(self): self.spec = ArgumentSpec() self.p1 = patch('time.sleep') self.p2 = patch( 'ansible_collections.f5networks.f5_bigip.plugins.modules.bigip_config.send_teem' ) self.p3 = patch( 'ansible_collections.f5networks.f5_bigip.plugins.modules.bigip_config.F5Client' ) self.p1.start() self.m2 = self.p2.start() self.m2.return_value = True self.m3 = self.p3.start() self.m3.return_value = MagicMock()