def test_snapshot_success(remove, revert, create): vm = VirtualMachine() with snapshot(vm): pass create.assert_called_once() revert.assert_called_once() remove.assert_called_once()
def test_snapshot_fail(remove, revert, create): vm = VirtualMachine() with pytest.raises(Exception): with snapshot(vm): raise Exception create.assert_called_once() revert.assert_called_once() remove.assert_called_once()
def test_snapshots(vms): snapshot_name = 'vcdriver_test_snapshot' for vm in vms.values(): with pytest.raises(NoObjectFound): vm.find_snapshot(snapshot_name) vm.create_snapshot(snapshot_name, True) with pytest.raises(TooManyObjectsFound): vm.create_snapshot(snapshot_name, True) vm.find_snapshot(snapshot_name) vm.revert_snapshot(snapshot_name) with snapshot(vm): pass
def test_snapshots(vms): snapshot_name = 'test_snapshot' for vm in vms.values(): vm.create() with pytest.raises(NoObjectFound): vm.find_snapshot(snapshot_name) vm.create_snapshot(snapshot_name, True) with pytest.raises(TooManyObjectsFound): vm.create_snapshot(snapshot_name, True) vm.find_snapshot(snapshot_name) assert vms['unix'].ssh('touch banana').return_code == 0 assert vms['unix'].ssh('ls') == 'banana' for vm in vms.values(): vm.revert_snapshot(snapshot_name) assert vms['unix'].ssh('ls') == '' with snapshot(vms['unix']): vms['unix'].ssh('touch banana') assert vms['unix'].ssh('ls') == 'banana' assert vms['unix'].ssh('ls') == ''