|
1 | 1 | importos |
| 2 | +importstat# for chmod |
2 | 3 | importunittest |
3 | 4 | from .helpers.ptrack_helpersimportdir_files,ProbackupTest,ProbackupException |
4 | 5 | importshutil |
@@ -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 | +deftest_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 | +assertos.access(backup_dir,os.R_OK)andnotos.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 | +exceptProbackupExceptionase: |
| 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 | deftest_abs_path(self): |
|