Browse Source

check_dd method [ADD] test case improved

pull/636/head
archetipo 9 years ago
committed by Dave Lasley
parent
commit
29f71c77df
  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/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################## ##############################################################################
import xmlrpclib
import socket import socket
import os import os
import time import time
@ -156,7 +155,7 @@ class DbBackup(models.Model):
@api.multi @api.multi
def _check_db_exist(self): def _check_db_exist(self):
for rec in 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: if rec.name in db_list:
return True return True
return False return False
@ -174,6 +173,7 @@ class DbBackup(models.Model):
# Check if there is a success or fail and write messages # Check if there is a success or fail and write messages
messageTitle = "" messageTitle = ""
messageContent = "" messageContent = ""
conn_success = False
for rec in confs: for rec in confs:
try: try:
conn_success = True conn_success = True

20
auto_backup/tests/test_auto_backup.py

@ -21,6 +21,8 @@
from openerp.tests import common from openerp.tests import common
from openerp.exceptions import except_orm from openerp.exceptions import except_orm
import os
import time
class TestsAutoBackup(common.TransactionCase): class TestsAutoBackup(common.TransactionCase):
@ -32,13 +34,23 @@ class TestsAutoBackup(common.TransactionCase):
def test_0(self): def test_0(self):
with self.assertRaises(except_orm): 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): def test_1(self):
this = self.abk_model.create( 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