diff --git a/auto_backup/model/backup_scheduler.py b/auto_backup/model/backup_scheduler.py index 4fd421196..479023ff5 100644 --- a/auto_backup/model/backup_scheduler.py +++ b/auto_backup/model/backup_scheduler.py @@ -18,7 +18,6 @@ # along with this program. If not, see . # ############################################################################## -import xmlrpclib import socket import os import time @@ -156,7 +155,7 @@ class DbBackup(models.Model): @api.multi def _check_db_exist(self): for rec in self: - db_list = self.get_db_list(rec.host, rec.port, rec.securehost) + db_list = db.exp_list(True) if rec.name in db_list: return True return False @@ -174,6 +173,7 @@ class DbBackup(models.Model): # Check if there is a success or fail and write messages messageTitle = "" messageContent = "" + conn_success = False for rec in confs: try: conn_success = True diff --git a/auto_backup/tests/test_auto_backup.py b/auto_backup/tests/test_auto_backup.py index 773fd6746..e2e6fee45 100644 --- a/auto_backup/tests/test_auto_backup.py +++ b/auto_backup/tests/test_auto_backup.py @@ -21,6 +21,8 @@ from openerp.tests import common from openerp.exceptions import except_orm +import os +import time class TestsAutoBackup(common.TransactionCase): @@ -32,13 +34,23 @@ class TestsAutoBackup(common.TransactionCase): def test_0(self): with self.assertRaises(except_orm): - self.abk_model.create({'name': 'abcd', 'adminpassword': 'admin'}) + self.abk_model.create( + { + 'name': 'abcd', + 'adminpassword': 'admin' + } + ) def test_1(self): this = self.abk_model.create( { - 'bkp_dir': '/tmp', - 'adminpassword': 'admin' + 'bkp_dir': '/tmp' } ) - self.assertEqual(this.host, 'localhost') + self.assertEqual(this.bkp_dir, '/tmp') + bkp_file = '%s_%s.dump.zip' % ( + time.strftime('%d_%m_%Y_%H_%M_%S'), + this.name) + file_path = os.path.join(this.bkp_dir, bkp_file) + this.schedule_backup() + self.assertTrue(os.path.isfile(file_path))