From e7e25f531aaacb8500ced5b456a8ffb11df51d6b Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Mon, 14 May 2018 10:22:21 -0500 Subject: [PATCH] Add tests for full_path() function This patch adds tests for the full_path() function. Signed-off-by: Major Hayden --- tests/test_executable.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/test_executable.py diff --git a/tests/test_executable.py b/tests/test_executable.py new file mode 100644 index 00000000..cec61091 --- /dev/null +++ b/tests/test_executable.py @@ -0,0 +1,38 @@ +""" +Test cases for runner module. +""" +# Copyright (c) 2018 Red Hat, Inc. All rights reserved. This copyrighted +# material is made available to anyone wishing to use, modify, copy, or +# redistribute it subject to the terms and conditions of the GNU General Public +# License v.2 or later. +# +# 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 skt import executable + + +class TestExecutable(unittest.TestCase): + """Test cases for executable module""" + + def test_full_path_relative(self): + """Verify that full_path() expands a relative path""" + filename = "somefile" + result = executable.full_path(filename) + expected_path = "{}/{}".format(os.getcwd(), filename) + self.assertEqual(expected_path, result) + + def test_full_path_user_directory(self): + """Verify that full_path() expands a user directory path""" + filename = "somefile" + result = executable.full_path("~/{}".format(filename)) + expected_path = "{}/{}".format(os.path.expanduser('~'), filename) + self.assertEqual(expected_path, result)