def test_no_compression_encrypt_should_run_actions_to_create_a_tar_file( self, mock: Mock): config = CloudConfig({ 'providers': [], 'encrypt': { 'strategy': 'gpg-passphrase', 'passphrase': '1' } }) backup_path = Path() folder = backup_path / 'folder' mock.side_effect = self._run_task_actions archive_folder(backup_path, folder, config) self.assertIsNotNone(self._actions) self.assertEqual(4, len(self._actions)) self._check_from_dir(folder) self._check_tar() self.assertDictEqual( { 'encrypt-gpg': { 'passphrase': '1', 'recipients': [], 'algorithm': None, }, }, self._actions[2]) self._check_to_file(folder, backup_path, '.asc', 3)
def test_no_compression_encrypt_with_no_encrypted_file_should_run_actions_to_create_file( self, mock: Mock): config = CloudConfig({ 'providers': [], 'encrypt': { 'strategy': 'gpg-passphrase', 'passphrase': '1' } }) task = self._generate_actions() backup_path = Path() path = backup_path / 'file.txt' mock.side_effect = self._run_task_actions filename = archive_file(backup_path, path, task, config) self.assertIsNotNone(filename) self.assertIsNotNone(self._actions) self.assertEqual(3, len(self._actions)) self._check_from_file(path) self.assertDictEqual( { 'encrypt-gpg': { 'passphrase': '1', 'recipients': [], 'algorithm': None, }, }, self._actions[1]) self._check_to_file(path, backup_path, '.asc', 2)
def test_compression_no_encrypt_should_run_actions_to_create_a_tar_file( self, mock: Mock): config = CloudConfig({ 'providers': [], 'compression': { 'method': 'br', 'cpus': 2 } }) backup_path = Path() folder = backup_path / 'folder' mock.side_effect = self._run_task_actions archive_folder(backup_path, folder, config) self.assertIsNotNone(self._actions) self.assertEqual(4, len(self._actions)) self._check_from_dir(folder) self._check_tar() self.assertDictEqual({ 'compress-br': { 'level': 6, 'cpus': 2, }, }, self._actions[2]) self._check_to_file(folder, backup_path, '.br', 3)
def test_compression_no_encrypt_with_no_compressed_file_should_run_actions_to_create_file( self, mock: Mock): config = CloudConfig({ 'providers': [], 'compression': { 'method': 'br', 'cpus': 2 } }) task = self._generate_actions() backup_path = Path() path = backup_path / 'file.txt' mock.side_effect = self._run_task_actions filename = archive_file(backup_path, path, task, config) self.assertIsNotNone(filename) self.assertIsNotNone(self._actions) self.assertEqual(3, len(self._actions)) self._check_from_file(path) self.assertDictEqual({ 'compress-br': { 'level': 6, 'cpus': 2, }, }, self._actions[1]) self._check_to_file(path, backup_path, '.br', 2)
def test_no_compression_no_encrypt_should_not_run_actions_and_return_none( self, mock: Mock): config = CloudConfig({'providers': []}) task = self._generate_actions() backup_path = Path() path = backup_path / 'file.txt' mock.side_effect = self._run_task_actions filename = archive_file(backup_path, path, task, config) self.assertIsNone(self._actions) self.assertIsNone(filename)
def test_no_compression_no_encrypt_should_run_actions_to_create_a_tar_file( self, mock: Mock): config = CloudConfig({'providers': []}) backup_path = Path() folder = backup_path / 'folder' mock.side_effect = self._run_task_actions archive_folder(backup_path, folder, config) self.assertIsNotNone(self._actions) self.assertEqual(3, len(self._actions)) self._check_from_dir(folder) self._check_tar() self._check_to_file(folder, backup_path)
def test_no_compression_encrypt_with_encrypted_file_should_run_actions_to_create_file( self, mock: Mock): config = CloudConfig({ 'providers': [], 'encrypt': { 'strategy': 'gpg-passphrase', 'passphrase': '1' } }) task = self._generate_actions(encrypted=True) backup_path = Path() path = backup_path / 'file.txt' mock.side_effect = self._run_task_actions filename = archive_file(backup_path, path, task, config) self.assertIsNone(filename) self.assertIsNone(self._actions)
def test_compression_no_encrypt_with_compressed_file_should_do_nothing( self, mock: Mock): config = CloudConfig({ 'providers': [], 'compression': { 'method': 'br', 'cpus': 2 } }) task = self._generate_actions(compressed=True) backup_path = Path() path = backup_path / 'file.txt' mock.side_effect = self._run_task_actions filename = archive_file(backup_path, path, task, config) self.assertIsNone(filename) self.assertIsNone(self._actions)