예제 #1
0
파일: miscTests.py 프로젝트: Caez83/vdsm
    def testFullDir(self, persist=False):
        """
        Test that rotator does it's basic functionality.
        """
        # Prepare
        prefix = "prefix"
        stubContent = ('"Multiple exclamation marks", '
                       'he went on, shaking his head, '
                       '"are a sure sign of a diseased mind."')
        # (C) Terry Pratchet - Small Gods
        with namedTemporaryDir() as dir:
            gen = 10

            expectedDirContent = []
            for i in range(gen):
                fname = "%s.txt.%d" % (prefix, i + 1)
                expectedDirContent.append("%s.txt.%d" % (prefix, i + 1))
                f = open(os.path.join(dir, fname), "wb")
                f.write(stubContent)
                f.flush()
                f.close()

            # Rotate
            misc.rotateFiles(dir, prefix, gen, persist=persist)

            # Test result
            currentDirContent = os.listdir(dir)
            expectedDirContent.sort()
            currentDirContent.sort()
            self.assertEquals(currentDirContent, expectedDirContent)
예제 #2
0
파일: miscTests.py 프로젝트: Caez83/vdsm
 def testEmptyDir(self, persist=False):
     """
     Test that when given an empty dir the rotator works correctly.
     """
     prefix = "prefix"
     with namedTemporaryDir() as dir:
         misc.rotateFiles(dir, prefix, 0, persist=persist)
예제 #3
0
 def testEmptyDir(self, persist=False):
     """
     Test that when given an empty dir the rotator works correctly.
     """
     prefix = "prefix"
     with namedTemporaryDir() as dir:
         misc.rotateFiles(dir, prefix, 0, persist=persist)
예제 #4
0
    def testFullDir(self, persist=False):
        """
        Test that rotator does it's basic functionality.
        """
        # Prepare
        prefix = "prefix"
        stubContent = ('"Multiple exclamation marks", '
                       'he went on, shaking his head, '
                       '"are a sure sign of a diseased mind."')
        # (C) Terry Pratchet - Small Gods
        with namedTemporaryDir() as dir:
            gen = 10

            expectedDirContent = []
            for i in range(gen):
                fname = "%s.txt.%d" % (prefix, i + 1)
                expectedDirContent.append("%s.txt.%d" % (prefix, i + 1))
                f = open(os.path.join(dir, fname), "wb")
                f.write(stubContent)
                f.flush()
                f.close()

            # Rotate
            misc.rotateFiles(dir, prefix, gen, persist=persist)

            # Test result
            currentDirContent = os.listdir(dir)
            expectedDirContent.sort()
            currentDirContent.sort()
            self.assertEquals(currentDirContent, expectedDirContent)
예제 #5
0
파일: miscTests.py 프로젝트: doronunu/vdsm
    def testEmptyDir(self, persist=False):
        """
        Test that when given an empty dir the rotator works correctly.
        """
        prefix = "prefix"
        dir = tempfile.mkdtemp()

        misc.rotateFiles(dir, prefix, 0, persist=persist)

        os.rmdir(dir)