qemu/tests/acceptance/vnc.py
Cleber Rosa 9531d26c10 Acceptance tests: drop usage of "🥑 enable"
The Avocado test runner attemps to find its INSTRUMENTED (that is,
Python based tests) in a manner that is as safe as possible to the
user.  Different from plain Python unittest, it won't load or
execute test code on an operation such as:

 $ avocado list tests/acceptance/

Before version 68.0, the logic implemented to identify INSTRUMENTED
tests would require either the "🥑 enable" or "🥑
recursive" statement as a flag for tests that would not inherit
directly from "avocado.Test".  This is not necessary anymore,
and because of that the boiler plate statements can now be removed.

Reference: https://avocado-framework.readthedocs.io/en/68.0/release_notes/68_0.html#users-test-writers
Signed-off-by: Cleber Rosa <crosa@redhat.com>
Reviewed-by: Caio Carrara <ccarrara@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
Message-Id: <20190218173723.26120-1-crosa@redhat.com>
Signed-off-by: Cleber Rosa <crosa@redhat.com>
2019-02-22 14:07:01 -05:00

60 lines
2.4 KiB
Python

# Simple functional tests for VNC functionality
#
# Copyright (c) 2018 Red Hat, Inc.
#
# Author:
# Cleber Rosa <crosa@redhat.com>
#
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.
from avocado_qemu import Test
class Vnc(Test):
"""
:avocado: tags=vnc,quick
"""
def test_no_vnc(self):
self.vm.add_args('-nodefaults', '-S')
self.vm.launch()
self.assertFalse(self.vm.qmp('query-vnc')['return']['enabled'])
def test_no_vnc_change_password(self):
self.vm.add_args('-nodefaults', '-S')
self.vm.launch()
self.assertFalse(self.vm.qmp('query-vnc')['return']['enabled'])
set_password_response = self.vm.qmp('change',
device='vnc',
target='password',
arg='new_password')
self.assertIn('error', set_password_response)
self.assertEqual(set_password_response['error']['class'],
'GenericError')
self.assertEqual(set_password_response['error']['desc'],
'Could not set password')
def test_vnc_change_password_requires_a_password(self):
self.vm.add_args('-nodefaults', '-S', '-vnc', ':0')
self.vm.launch()
self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
set_password_response = self.vm.qmp('change',
device='vnc',
target='password',
arg='new_password')
self.assertIn('error', set_password_response)
self.assertEqual(set_password_response['error']['class'],
'GenericError')
self.assertEqual(set_password_response['error']['desc'],
'Could not set password')
def test_vnc_change_password(self):
self.vm.add_args('-nodefaults', '-S', '-vnc', ':0,password')
self.vm.launch()
self.assertTrue(self.vm.qmp('query-vnc')['return']['enabled'])
set_password_response = self.vm.qmp('change',
device='vnc',
target='password',
arg='new_password')
self.assertEqual(set_password_response['return'], {})