def test_constructor(self): inode_no = self.tmp_file_a.stat().st_ino vault_file_key_path = VFK(T.Path("a"), inode_no).path vault_file_path = self._path / \ T.Path("parent_dir/child_dir_one/.vault/keep") / \ vault_file_key_path # Test source and path self.assertEqual(VaultFile(vault=self.vault, branch=Branch.Keep, path=self.tmp_file_a).path, vault_file_path) self.assertEqual(VaultFile(vault=self.vault, branch=Branch.Keep, path=self.tmp_file_a).source, self.tmp_file_a)
def _perms_and_check(self, u: int, g: int, o: int) -> bool: """ Change the permissions of self.perms_mod to `ugo` as passed, and runs can_add against that file """ self.perms_mod.chmod(int(f"{u}{g}{o}", 8)) return VaultFile(self.vault, Branch.Keep, self.perms_mod).can_add
def test_can_add_not_regular_file(self): """ We shouldn't be able to add a file that isn't regular. It can be rejected in either the initialisation of the VaultFile or during the can_add checks. We're happy with either. """ res = False try: res = VaultFile(self.vault, Branch.Keep, self.child_dir_one).can_add except exception.NotRegularFile: res = True return res
def test_can_remove_not_added(self): self.assertEqual(VaultFile( vault=self.vault, branch=Branch.Keep, path=self.tmp_file_a).can_remove, True)
def test_can_add_all_good_to_add_file(self): """A file with all the right permissions should be able to be added""" self.assertTrue( VaultFile(self.vault, Branch.Keep, self.tmp_file_a), True)
def _parent_dir_perms_and_check(u: int, g: int, o: int) -> bool: self.perms_mod_dir.chmod(int(f"{u}{g}{o}", 8)) return VaultFile(self.vault, Branch.Keep, self.tmp_file_d).can_add