Move FillDict at module level
[ganeti-local] / test / testutils.py
index f2980dd..c0932cc 100644 (file)
@@ -22,6 +22,7 @@
 """Utilities for unit testing"""
 
 import os
 """Utilities for unit testing"""
 
 import os
+import stat
 import tempfile
 import unittest
 
 import tempfile
 import unittest
 
@@ -46,7 +47,7 @@ class GanetiTestCase(unittest.TestCase):
         pass
 
   def assertFileContent(self, file_name, expected_content):
         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
 
     @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)
 
     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.
   @staticmethod
   def _TestDataFilename(name):
     """Returns the filename of a given test data file.