예제 #1
0
    def test_finds_rotated_files(self):
        rotated_files = list(rotator._rotated_files("tests/test_dir_a/mydump"))
        self.assertEqual(len(rotated_files), 5)

        first_path, first_rotation_id = rotated_files[0]
        # no guaranteed order to the globbing, so this cannot verify exactly
        self.assertRegexpMatches(
            first_path,
            "tests\/test_dir_a\/mydump.*2015-12-02.*\.backup-[3-7].*")
        self.assertGreaterEqual(first_rotation_id, 3)
예제 #2
0
    def test_locate_files_to_delete(self):
        rotated_files = list(rotator._rotated_files("tests/test_dir_a/mydump"))

        # 5 slots
        to_delete = list(rotator._locate_files_to_delete(
            SimpleRotator(5), rotated_files, 8))
        self.assertEqual(len(to_delete), 1)

        # 10 slots (don't delete anything)
        to_delete = list(rotator._locate_files_to_delete(
            SimpleRotator(10), rotated_files, 8))
        self.assertEqual(len(to_delete), 0)

        # 2 slots (delete a #4 and #6)
        to_delete = list(rotator._locate_files_to_delete(
            SimpleRotator(2), rotated_files, 8))
        self.assertEqual(len(to_delete), 2)
예제 #3
0
 def test_finds_next_rotation_id(self):
     rotated_files = list(rotator._rotated_files("tests/test_dir_a/mydump"))
     x = rotator._next_rotation_id(rotated_files)
     self.assertEqual(x, 8)
예제 #4
0
 def test_next_rotation_id_is_0_without_match(self):
     rotated_files = list(rotator._rotated_files("tests/test_dir_a/foo"))
     x = rotator._next_rotation_id(rotated_files)
     self.assertEqual(x, 0)
예제 #5
0
 def test_rotated_files_respects_name(self):
     # there are no files matching "another_name"
     rotated_files = list(rotator._rotated_files("tests/test_dir_a/foo"))
     self.assertEqual(len(rotated_files), 0)