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_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)