mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
Add missing python bindings tests
Signed-off-by: Hiroyuki Katsura <hiroyuki.katsura.0513@gmail.com>
This commit is contained in:
committed by
Richard W.M. Jones
parent
a4ef6716b4
commit
7772cfc771
23
python/t/test020Create.py
Normal file
23
python/t/test020Create.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# libguestfs Python bindings
|
||||
# Copyright (C) 2019 Red Hat Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import unittest
|
||||
import guestfs
|
||||
|
||||
class Test020Create(unittest.TestCase):
|
||||
def test_create(self):
|
||||
_ = guestfs.GuestFS(python_return_dict=True)
|
||||
25
python/t/test030CreateFlags.py
Normal file
25
python/t/test030CreateFlags.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# libguestfs Python bindings
|
||||
# Copyright (C) 2019 Red Hat Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import unittest
|
||||
import guestfs
|
||||
|
||||
class Test030CreateFlags(unittest.TestCase):
|
||||
def test_create_flags(self):
|
||||
g = guestfs.GuestFS(python_return_dict=True,
|
||||
environment=False)
|
||||
g.parse_environment()
|
||||
29
python/t/test040CreateMultiple.py
Normal file
29
python/t/test040CreateMultiple.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# libguestfs Python bindings
|
||||
# Copyright (C) 2019 Red Hat Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import unittest
|
||||
import guestfs
|
||||
|
||||
def ignore(_):
|
||||
pass
|
||||
|
||||
class Test040CreateMultiple(unittest.TestCase):
|
||||
def test_create_multiple(self):
|
||||
g1 = guestfs.GuestFS(python_return_dict=True)
|
||||
g2 = guestfs.GuestFS(python_return_dict=True)
|
||||
g3 = guestfs.GuestFS(python_return_dict=True)
|
||||
ignore((g1, g2, g3))
|
||||
47
python/t/test050HandleProperties.py
Normal file
47
python/t/test050HandleProperties.py
Normal file
@@ -0,0 +1,47 @@
|
||||
# libguestfs Python bindings
|
||||
# Copyright (C) 2019 Red Hat Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import unittest
|
||||
import guestfs
|
||||
|
||||
class Test050HandleProperties(unittest.TestCase):
|
||||
def test_verbose(self):
|
||||
g = guestfs.GuestFS(python_return_dict=True)
|
||||
g.set_verbose(1)
|
||||
self.assertEqual(g.get_verbose(), 1)
|
||||
g.set_verbose(0)
|
||||
self.assertEqual(g.get_verbose(), 0)
|
||||
|
||||
def test_autosync(self):
|
||||
g = guestfs.GuestFS(python_return_dict=True)
|
||||
g.set_autosync(1)
|
||||
self.assertEqual(g.get_autosync(), 1)
|
||||
g.set_autosync(0)
|
||||
self.assertEqual(g.get_autosync(), 0)
|
||||
|
||||
def test_path(self):
|
||||
g = guestfs.GuestFS(python_return_dict=True)
|
||||
g.set_path(".")
|
||||
self.assertEqual(g.get_path(), ".")
|
||||
|
||||
def test_add_drive(self):
|
||||
g = guestfs.GuestFS(python_return_dict=True)
|
||||
g.add_drive("/dev/null")
|
||||
|
||||
def test_add_cdrom(self):
|
||||
g = guestfs.GuestFS(python_return_dict=True)
|
||||
g.add_cdrom("/dev/zero")
|
||||
50
python/t/test430ProgressMessages.py
Normal file
50
python/t/test430ProgressMessages.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# libguestfs Python bindings
|
||||
# Copyright (C) 2019 Red Hat Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import guestfs
|
||||
|
||||
callback_invoked = 0
|
||||
|
||||
def callback(ev, eh, buf, array):
|
||||
global callback_invoked
|
||||
callback_invoked += 1
|
||||
|
||||
class Test430ProgressMessages(unittest.TestCase):
|
||||
def test_progress_messages(self):
|
||||
global callback_invoked
|
||||
g = guestfs.GuestFS(python_return_dict=True)
|
||||
g.add_drive('/dev/null')
|
||||
g.launch()
|
||||
|
||||
events = guestfs.EVENT_PROGRESS
|
||||
|
||||
eh = g.set_event_callback(callback, events)
|
||||
g.debug('progress', ['5'])
|
||||
self.assertTrue(callback_invoked > 0)
|
||||
|
||||
callback_invoked = 0
|
||||
g.delete_event_callback(eh)
|
||||
g.debug('progress', ['5'])
|
||||
self.assertEqual(callback_invoked, 0)
|
||||
|
||||
g.set_event_callback(callback, events)
|
||||
g.debug('progress', ['5'])
|
||||
self.assertTrue(callback_invoked > 0)
|
||||
|
||||
g.close()
|
||||
Reference in New Issue
Block a user