class MediabackupCleanUpOldBackupsTest(TestCase):
    def setUp(self):
        self.skipTest("Doesn't work!")
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.storage = FakeStorage()

    def test_func(self):
        self.command.cleanup_old_backups()
class MediabackupCleanUpOldBackupsTest(TestCase):
    def setUp(self):
        self.skipTest("Doesn't work!")
        self.command = DbbackupCommand()
        self.command.servername = "foo-server"
        self.command.storage = FakeStorage()

    def test_func(self):
        self.command.cleanup_old_backups()
Beispiel #3
0
class MediabackupGetBackupFileListTest(TestCase):
    def setUp(self):
        self.skipTest("Doesn't work!")
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.storage = FakeStorage()

    def test_func(self):
        self.command.get_backup_file_list()
class MediabackupGetBackupFileListTest(TestCase):
    def setUp(self):
        self.skipTest("Doesn't work!")
        self.command = DbbackupCommand()
        self.command.servername = "foo-server"
        self.command.storage = FakeStorage()

    def test_func(self):
        self.command.get_backup_file_list()
class MediabackupGetServerNameTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()

    def test_func(self):
        self.command.servername = 'foo-server'
        self.command.get_servername()

    def test_no_servername(self):
        self.command.servername = ''
        self.command.get_servername()
class MediabackupGetServerNameTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()

    def test_func(self):
        self.command.servername = "foo-server"
        self.command.get_servername()

    def test_no_servername(self):
        self.command.servername = ""
        self.command.get_servername()
Beispiel #7
0
class MediabackupBackupMediafilesTest(TestCase):
    def setUp(self):
        HANDLED_FILES.clean()
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.storage = get_storage()
        self.command.stdout = DEV_NULL
        self.command.compress = False
        self.command.encrypt = False
        self.command.path = None
        self.command.media_storage = get_storage_class()()

    def tearDown(self):
        if self.command.path is not None:
            try:
                os.remove(self.command.path)
            except OSError:
                pass

    def test_func(self):
        self.command.backup_mediafiles()
        self.assertEqual(1, len(HANDLED_FILES['written_files']))

    def test_compress(self):
        self.command.compress = True
        self.command.backup_mediafiles()
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        self.assertTrue(HANDLED_FILES['written_files'][0][0].endswith('.gz'))

    def test_encrypt(self):
        self.command.encrypt = True
        add_public_gpg()
        self.command.backup_mediafiles()
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        outputfile = HANDLED_FILES['written_files'][0][1]
        outputfile.seek(0)
        self.assertTrue(outputfile.read().startswith(b'-----BEGIN PGP MESSAGE-----'))

    def test_compress_and_encrypt(self):
        self.command.compress = True
        self.command.encrypt = True
        add_public_gpg()
        self.command.backup_mediafiles()
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        outputfile = HANDLED_FILES['written_files'][0][1]
        outputfile.seek(0)
        self.assertTrue(outputfile.read().startswith(b'-----BEGIN PGP MESSAGE-----'))

    def test_write_local_file(self):
        self.command.path = tempfile.mktemp()
        self.command.backup_mediafiles()
        self.assertTrue(os.path.exists(self.command.path))
        self.assertEqual(0, len(HANDLED_FILES['written_files']))
class MediabackupBackupMediafilesTest(TestCase):
    def setUp(self):
        HANDLED_FILES.clean()
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL

    def test_func(self):
        self.command.backup_mediafiles(encrypt=False, compress=False)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))

    def test_compress(self):
        self.command.backup_mediafiles(encrypt=False, compress=True)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        self.assertTrue(HANDLED_FILES['written_files'][0][0].endswith('.gz'))

    def test_encrypt(self):
        add_public_gpg()
        self.command.backup_mediafiles(encrypt=True, compress=False)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        outputfile = HANDLED_FILES['written_files'][0][1]
        outputfile.seek(0)
        self.assertTrue(outputfile.read().startswith(b'-----BEGIN PGP MESSAGE-----'))

    def test_compress_and_encrypt(self):
        add_public_gpg()
        self.command.backup_mediafiles(encrypt=True, compress=True)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        outputfile = HANDLED_FILES['written_files'][0][1]
        outputfile.seek(0)
        self.assertTrue(outputfile.read().startswith(b'-----BEGIN PGP MESSAGE-----'))
class MediabackupBackupMediafilesTest(TestCase):
    def setUp(self):
        HANDLED_FILES.clean()
        self.command = DbbackupCommand()
        self.command.servername = "foo-server"
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL

    def test_func(self):
        self.command.backup_mediafiles(encrypt=False, compress=False)
        self.assertEqual(1, len(HANDLED_FILES["written_files"]))

    def test_compress(self):
        self.command.backup_mediafiles(encrypt=False, compress=True)
        self.assertEqual(1, len(HANDLED_FILES["written_files"]))
        self.assertTrue(HANDLED_FILES["written_files"][0][0].endswith(".gz"))

    def test_encrypt(self):
        cmd = ("gpg --import %s" % GPG_PUBLIC_PATH).split()
        subprocess.call(cmd, stdout=DEV_NULL, stderr=DEV_NULL)
        self.command.backup_mediafiles(encrypt=True, compress=False)
        self.assertEqual(1, len(HANDLED_FILES["written_files"]))
        outputfile = HANDLED_FILES["written_files"][0][1]
        outputfile.seek(0)
        self.assertTrue(outputfile.read().startswith(b"-----BEGIN PGP MESSAGE-----"))

    def test_compress_and_encrypt(self):
        cmd = ("gpg --import %s" % GPG_PUBLIC_PATH).split()
        subprocess.call(cmd, stdout=DEV_NULL, stderr=DEV_NULL)
        self.command.backup_mediafiles(encrypt=True, compress=True)
        self.assertEqual(1, len(HANDLED_FILES["written_files"]))
        outputfile = HANDLED_FILES["written_files"][0][1]
        outputfile.seek(0)
        self.assertTrue(outputfile.read().startswith(b"-----BEGIN PGP MESSAGE-----"))
Beispiel #10
0
class MediabackupBackupMediafilesTest(TestCase):
    def setUp(self):
        HANDLED_FILES.clean()
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL

    def test_func(self):
        self.command.backup_mediafiles(encrypt=False, compress=False)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))

    def test_compress(self):
        self.command.backup_mediafiles(encrypt=False, compress=True)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        self.assertTrue(HANDLED_FILES['written_files'][0][0].endswith('.gz'))

    def test_encrypt(self):
        add_public_gpg()
        self.command.backup_mediafiles(encrypt=True, compress=False)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        outputfile = HANDLED_FILES['written_files'][0][1]
        outputfile.seek(0)
        self.assertTrue(
            outputfile.read().startswith(b'-----BEGIN PGP MESSAGE-----'))

    def test_compress_and_encrypt(self):
        add_public_gpg()
        self.command.backup_mediafiles(encrypt=True, compress=True)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        outputfile = HANDLED_FILES['written_files'][0][1]
        outputfile.seek(0)
        self.assertTrue(
            outputfile.read().startswith(b'-----BEGIN PGP MESSAGE-----'))
class MediabackupBackupMediafilesTest(TestCase):
    def setUp(self):
        HANDLED_FILES.clean()
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL

    def test_func(self):
        self.command.backup_mediafiles(encrypt=False, compress=False)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))

    def test_compress(self):
        self.command.backup_mediafiles(encrypt=False, compress=True)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        self.assertTrue(HANDLED_FILES['written_files'][0][0].endswith('.gz'))

    def test_encrypt(self):
        cmd = ('gpg --import %s' % GPG_PUBLIC_PATH).split()
        subprocess.call(cmd, stdout=DEV_NULL, stderr=DEV_NULL)
        self.command.backup_mediafiles(encrypt=True, compress=False)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        outputfile = HANDLED_FILES['written_files'][0][1]
        outputfile.seek(0)
        self.assertTrue(outputfile.read().startswith(b'-----BEGIN PGP MESSAGE-----'))

    def test_compress_and_encrypt(self):
        cmd = ('gpg --import %s' % GPG_PUBLIC_PATH).split()
        subprocess.call(cmd, stdout=DEV_NULL, stderr=DEV_NULL)
        self.command.backup_mediafiles(encrypt=True, compress=True)
        self.assertEqual(1, len(HANDLED_FILES['written_files']))
        outputfile = HANDLED_FILES['written_files'][0][1]
        outputfile.seek(0)
        self.assertTrue(outputfile.read().startswith(b'-----BEGIN PGP MESSAGE-----'))
 def setUp(self):
     HANDLED_FILES.clean()
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.storage = get_storage()
     self.command.stdout = DEV_NULL
     self.command.compress = False
     self.command.encrypt = False
     self.command.path = None
     self.command.media_storage = get_storage_class()()
Beispiel #13
0
class MediabackupCleanUpOldBackupsTest(TestCase):
    def setUp(self):
        HANDLED_FILES.clean()
        self.command = DbbackupCommand()
        self.command.stdout = DEV_NULL
        self.command.encrypt = False
        self.command.compress = False
        self.command.servername = 'foo-server'
        self.command.storage = FakeStorage()
        HANDLED_FILES['written_files'] = [(f, None) for f in [
            '2015-02-06-042810.bak',
            '2015-02-07-042810.bak',
            '2015-02-08-042810.bak',
        ]]

    @patch('dbbackup.settings.CLEANUP_KEEP_MEDIA', 1)
    def test_func(self):
        self.command.cleanup_old_backups()
        self.assertEqual(2, len(HANDLED_FILES['deleted_files']))
Beispiel #14
0
class MediabackupCleanUpOldBackupsTest(TestCase):
    def setUp(self):
        HANDLED_FILES.clean()
        self.command = DbbackupCommand()
        self.command.stdout = DEV_NULL
        self.command.encrypt = False
        self.command.compress = False
        self.command.servername = 'foo-server'
        self.command.storage = FakeStorage()
        HANDLED_FILES['written_files'] = [(f, None) for f in [
            '2015-02-06-042810.bak',
            '2015-02-07-042810.bak',
            '2015-02-08-042810.bak',
        ]]

    @patch('dbbackup.settings.CLEANUP_KEEP_MEDIA', 1)
    def test_func(self):
        self.command.cleanup_old_backups()
        self.assertEqual(2, len(HANDLED_FILES['deleted_files']))
 def setUp(self):
     HANDLED_FILES.clean()
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.storage = get_storage()
     self.command.stdout = DEV_NULL
     self.command.compress = False
     self.command.encrypt = False
     self.command.path = None
     self.command.media_storage = get_storage_class()()
Beispiel #16
0
 def setUp(self):
     HANDLED_FILES.clean()
     self.command = DbbackupCommand()
     self.command.stdout = DEV_NULL
     self.command.encrypt = False
     self.command.compress = False
     self.command.servername = 'foo-server'
     self.command.storage = FakeStorage()
     HANDLED_FILES['written_files'] = [(f, None) for f in [
         '2015-02-06-042810.bak',
         '2015-02-07-042810.bak',
         '2015-02-08-042810.bak',
     ]]
Beispiel #17
0
 def setUp(self):
     HANDLED_FILES.clean()
     self.command = DbbackupCommand()
     self.command.stdout = DEV_NULL
     self.command.encrypt = False
     self.command.compress = False
     self.command.servername = 'foo-server'
     self.command.storage = FakeStorage()
     HANDLED_FILES['written_files'] = [(f, None) for f in [
         '2015-02-06-042810.bak',
         '2015-02-07-042810.bak',
         '2015-02-08-042810.bak',
     ]]
class MediabackupGetBackupBasenameTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.servername = "foo-server"
        self.command.storage = FakeStorage()

    def test_func(self):
        output = self.command.get_backup_basename()
        self.assertTrue(output.endswith(".tar"))

    def test_compress(self):
        options = {"compress": True}
        output = self.command.get_backup_basename(**options)
        self.assertTrue(output.endswith(".tar.gz"))

    def test_encrypt(self):
        options = {"compress": True}
        output = self.command.get_backup_basename(**options)
        self.assertTrue(output.endswith(".tar.gz"))

    def test_compress_and_encrypt(self):
        options = {"compress": True}
        output = self.command.get_backup_basename(**options)
        self.assertTrue(output.endswith(".tar.gz"))
Beispiel #19
0
class MediabackupGetBackupBasenameTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.storage = FakeStorage()

    def test_func(self):
        output = self.command.get_backup_basename()
        self.assertTrue(output.endswith('.tar'))

    def test_compress(self):
        options = {'compress': True}
        output = self.command.get_backup_basename(**options)
        self.assertTrue(output.endswith('.tar.gz'))

    def test_encrypt(self):
        options = {'compress': True}
        output = self.command.get_backup_basename(**options)
        self.assertTrue(output.endswith('.tar.gz'))

    def test_compress_and_encrypt(self):
        options = {'compress': True}
        output = self.command.get_backup_basename(**options)
        self.assertTrue(output.endswith('.tar.gz'))
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.servername = "foo-server"
     self.command.storage = FakeStorage()
 def setUp(self):
     HANDLED_FILES.clean()
     self.command = DbbackupCommand()
     self.command.servername = "foo-server"
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
Beispiel #22
0
 def setUp(self):
     HANDLED_FILES.clean()
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
Beispiel #23
0
 def setUp(self):
     self.skipTest("Doesn't work!")
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.storage = FakeStorage()
Beispiel #24
0
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.storage = FakeStorage()
 def setUp(self):
     self.command = DbbackupCommand()
 def setUp(self):
     self.skipTest("Doesn't work!")
     self.command = DbbackupCommand()
     self.command.servername = "foo-server"
     self.command.storage = FakeStorage()
 def setUp(self):
     self.command = DbbackupCommand()