X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/51596eb2c8b20e8d7dd01e23fe76625e82cf17c3..abe609b211ea257f4e080038dbb46ca1edc018f3:/test/testutils.py diff --git a/test/testutils.py b/test/testutils.py index f2980dd..c0932cc 100644 --- a/test/testutils.py +++ b/test/testutils.py @@ -22,6 +22,7 @@ """Utilities for unit testing""" import os +import stat import tempfile import unittest @@ -46,7 +47,7 @@ class GanetiTestCase(unittest.TestCase): pass def assertFileContent(self, file_name, expected_content): - """Checks the content of a file is what we expect. + """Checks that the content of a file is what we expect. @type file_name: str @param file_name: the file whose contents we should check @@ -57,6 +58,19 @@ class GanetiTestCase(unittest.TestCase): actual_content = utils.ReadFile(file_name) self.assertEqual(actual_content, expected_content) + def assertFileMode(self, file_name, expected_mode): + """Checks that the mode of a file is what we expect. + + @type file_name: str + @param file_name: the file whose contents we should check + @type expected_mode: int + @param expected_mode: the mode we expect + + """ + st = os.stat(file_name) + actual_mode = stat.S_IMODE(st.st_mode) + self.assertEqual(actual_mode, expected_mode) + @staticmethod def _TestDataFilename(name): """Returns the filename of a given test data file.