def test_remove_host_fail(self): """Verify remove_host produces expected exceptions.""" with self.assertRaisesRegexp(AnsibleFailJson, "Failed to remove host."): with mock.patch(self.REQ_FUNC, return_value=Exception()): self._set_args({ 'state': 'absent', 'name': 'beegfs_metadata1', 'host_type': 'linux dm-mp', 'force_port': False, 'group': 'test_group', 'ports': [{ 'label': 'beegfs_metadata1_iscsi_0', 'type': 'iscsi', 'port': 'iqn.1993-08.org.debian.beegfs-metadata:01:69e4efdf30b8' }] }) host = Host() host.host_obj = { "id": "84000000600A098000A4B9D10030370B5D430109" } host.remove_host()
def test_remove_host_pass(self): """Verify remove_host produces expected results.""" with mock.patch(self.REQ_FUNC, return_value=(200, None)): self._set_args({ 'state': 'absent', 'name': 'beegfs_metadata1', 'host_type': 'linux dm-mp', 'force_port': False, 'group': 'test_group', 'ports': [{ 'label': 'beegfs_metadata1_iscsi_0', 'type': 'iscsi', 'port': 'iqn.1993-08.org.debian.beegfs-metadata:01:69e4efdf30b8' }] }) host = Host() host.host_obj = {"id": "84000000600A098000A4B9D10030370B5D430109"} host.remove_host()