|
1 | 1 | import os
|
| 2 | +import stat # for chmod |
2 | 3 | import unittest
|
3 | 4 | from .helpers.ptrack_helpers import dir_files, ProbackupTest, ProbackupException
|
4 | 5 | import shutil
|
@@ -86,6 +87,29 @@ def test_already_exist(self):
|
86 | 87 |
|
87 | 88 | # Clean after yourself
|
88 | 89 | self.del_test_dir(module_name, fname)
|
| 90 | + |
| 91 | + # @unittest.skip("skip") |
| 92 | + def test_no_rights_for_directory(self): |
| 93 | + """Failure with backup catalog existed and empty but user has no writing permissions""" |
| 94 | + fname = self.id().split(".")[3] |
| 95 | + backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') |
| 96 | + os.mkdir(backup_dir) |
| 97 | + os.chmod(backup_dir, stat.S_IREAD) # set read-only flag for current user |
| 98 | + assert os.access(backup_dir, os.R_OK) and not os.access(backup_dir, os.W_OK) |
| 99 | + node = self.make_simple_node(base_dir=os.path.join(module_name, fname, 'node')) |
| 100 | + self.init_pb(backup_dir) |
| 101 | + try: |
| 102 | + self.show_pb(backup_dir, 'node') |
| 103 | + self.assertEqual(1, 0, 'Expecting Error due to initialization in empty directory with no rithts for writing. Output: {0} \n CMD: {1}'.format( |
| 104 | + repr(self.output), self.cmd)) |
| 105 | + except ProbackupException as e: |
| 106 | + self.assertIn( |
| 107 | + "ERROR: Instance 'node' does not exist in this backup catalog", |
| 108 | + e.message, |
| 109 | + '\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd)) |
| 110 | + |
| 111 | + # Clean after yourself |
| 112 | + self.del_test_dir(module_name, fname) |
89 | 113 |
|
90 | 114 | # @unittest.skip("skip")
|
91 | 115 | def test_abs_path(self):
|
|
0 commit comments