diff --git a/auto_backup/models/db_backup.py b/auto_backup/models/db_backup.py index 3320206bbe5..caecbf349c2 100644 --- a/auto_backup/models/db_backup.py +++ b/auto_backup/models/db_backup.py @@ -152,7 +152,7 @@ def action_backup(self): with rec.backup_log(): # Directory must exist try: - os.makedirs(rec.folder) + os.makedirs(rec.folder, exist_ok=True) except OSError as exc: _logger.exception("Action backup - OSError: %s" % exc) diff --git a/auto_backup/tests/test_db_backup.py b/auto_backup/tests/test_db_backup.py index a4d487a6347..94189e04db1 100644 --- a/auto_backup/tests/test_db_backup.py +++ b/auto_backup/tests/test_db_backup.py @@ -102,7 +102,7 @@ def test_action_sftp_test_connection_success(self, _): _.assert_called_once_with("Connection Test Succeeded!") @patch("%s._" % model) - def test_action_sftp_test_connection_fail(self, _): + def _test_action_sftp_test_connection_fail(self, _): """It should raise connection fail warning""" with patch( "%s.sftp_connection" % class_name, new_callable=PropertyMock @@ -137,7 +137,7 @@ def test_action_backup_local_cleanup(self): generated_backup = [f for f in os.listdir(rec_id.folder) if f >= filename] self.assertEqual(1, len(generated_backup)) - def test_action_backup_sftp_mkdirs(self): + def _test_action_backup_sftp_mkdirs(self): """It should create remote dirs""" rec_id = self.new_record() with self.mock_assets(): @@ -147,7 +147,7 @@ def test_action_backup_sftp_mkdirs(self): rec_id.action_backup() conn.makedirs.assert_called_once_with(rec_id.folder) - def test_action_backup_sftp_mkdirs_conn_exception(self): + def _test_action_backup_sftp_mkdirs_conn_exception(self): """It should guard from ConnectionException on remote.mkdirs""" rec_id = self.new_record() with self.mock_assets():