From 09a53eb2a3c4609b3e373d7250181051d3a6f0e6 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 18 Oct 2017 17:44:29 -0400 Subject: [PATCH] tests: Add basic hostkeymap test To validate an upcoming bugfix --- tests/hostkeymap.py | 36 +++++++++++++++++++++++++ tests/hostkeymap/sysconfig-comments.txt | 13 +++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/hostkeymap.py create mode 100644 tests/hostkeymap/sysconfig-comments.txt diff --git a/tests/hostkeymap.py b/tests/hostkeymap.py new file mode 100644 index 000000000..c09e48cd8 --- /dev/null +++ b/tests/hostkeymap.py @@ -0,0 +1,36 @@ +# Copyright (C) 2017 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 os +import unittest + +from virtinst import hostkeymap + + +class TestHostkeymap(unittest.TestCase): + """ + Tests for hostkeymap.py file parsing + """ + def testFiles(self): + def _open(filename): + return file(os.path.join(os.getcwd(), + "tests/hostkeymap", filename)) + + self.assertEquals( + hostkeymap._sysconfig_keyboard(_open("sysconfig-comments.txt")), + "de-latin1-nodeadkeys") + diff --git a/tests/hostkeymap/sysconfig-comments.txt b/tests/hostkeymap/sysconfig-comments.txt new file mode 100644 index 000000000..499473422 --- /dev/null +++ b/tests/hostkeymap/sysconfig-comments.txt @@ -0,0 +1,13 @@ +# Path: Hardware/Keyboard +## Description: Keyboard settings +## Type: string +## Default: "" +## ServiceRestart: kbd +# +# Keyboard settings for the text console +# +# Keyboard mapping +# (/usr/share/kbd/keymaps/) +# e.g. KEYTABLE="de-latin1-nodeadkeys", "us" or empty for US settings +# +KEYTABLE=""