You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.2 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Copyright 2015 Agile Business Group <http://www.agilebg.com>
  5. # Copyright (C) 2015 Alessio Gerace <alesiso.gerace@agilebg.com>
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as
  9. # published by the Free Software Foundation, either version 3 of the
  10. # License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. import base64
  22. from openerp.tests import common
  23. from openerp.exceptions import except_orm, Warning
  24. from openerp.modules.module import get_module_resource
  25. import os
  26. import time
  27. from datetime import datetime, date, timedelta
  28. class TestsAutoBackup(common.TransactionCase):
  29. def setUp(self):
  30. super(TestsAutoBackup, self).setUp()
  31. self.abk_model = self.env["db.backup"]
  32. self.cron_model = self.env["ir.cron"]
  33. def test_0(self):
  34. with self.assertRaises(except_orm):
  35. self.abk_model.create({'name': 'abcd'})
  36. def test_1(self):
  37. this = self.abk_model.create(
  38. {
  39. 'bkp_dir': '/tmp'
  40. }
  41. )
  42. self.assertEqual(this.host, 'localhost')
  43. cronbk = self.cron_model.search([('name', '=', 'Backup scheduler')])
  44. import pdb;pdb.set_trace()
  45. cronbk.write(
  46. {
  47. 'active': True,
  48. 'doall': True
  49. }
  50. )
  51. filetime = (
  52. datetime.now() + timedelta(minutes=1)
  53. ).strftime('%d_%m_%Y_%H_%M_%S')
  54. bkp_file = '%s_%s.dimp.zip' % (
  55. filetime, this.name)
  56. file_path = os.path.join(this.bkp_dir, bkp_file)
  57. self.assertEqual(os.path.isfile(file_path), True)