Browse Source

[FIX] check_dd method

[ADD] test case improved
pull/203/head
archetipo 9 years ago
parent
commit
c265d9beae
  1. 4
      auto_backup/model/backup_scheduler.py
  2. 20
      auto_backup/tests/test_auto_backup.py

4
auto_backup/model/backup_scheduler.py

@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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

20
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))
Loading…
Cancel
Save