class DbbackupCommandSaveNewBackupTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.encrypt = False
        self.command.compress = False
        self.command.database = TEST_DATABASE['NAME']
        self.command.storage = FakeStorage()
        self.command.connector = get_connector()
        self.command.stdout = DEV_NULL
        self.command.filename = None
        self.command.path = None

    def tearDown(self):
        clean_gpg_keys()

    def test_func(self):
        self.command._save_new_backup(TEST_DATABASE)

    def test_compress(self):
        self.command.compress = True
        self.command._save_new_backup(TEST_DATABASE)

    def test_encrypt(self):
        add_public_gpg()
        self.command.encrypt = True
        self.command._save_new_backup(TEST_DATABASE)

    def test_path(self):
        self.command.path = '/tmp/foo.bak'
        self.command._save_new_backup(TEST_DATABASE)
        self.assertTrue(os.path.exists(self.command.path))
        # tearDown
        os.remove(self.command.path)
class DbbackupCommandSaveNewBackupTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.encrypt = False
        self.command.compress = False
        self.command.database = TEST_DATABASE['NAME']
        self.command.storage = get_storage()
        self.command.connector = get_connector()
        self.command.stdout = DEV_NULL
        self.command.filename = None
        self.command.path = None

    def tearDown(self):
        clean_gpg_keys()

    def test_func(self):
        self.command._save_new_backup(TEST_DATABASE)

    def test_compress(self):
        self.command.compress = True
        self.command._save_new_backup(TEST_DATABASE)

    def test_encrypt(self):
        add_public_gpg()
        self.command.encrypt = True
        self.command._save_new_backup(TEST_DATABASE)

    def test_path(self):
        self.command.path = '/tmp/foo.bak'
        self.command._save_new_backup(TEST_DATABASE)
        self.assertTrue(os.path.exists(self.command.path))
        # tearDown
        os.remove(self.command.path)
class DbbackupCommandCompressFileTest(TestCase):
    def setUp(self):
        if six.PY3:
            self.skipTest("Compression isn't implemented in Python3")
        open(TEST_DATABASE['NAME'], 'a+b').close()
        self.command = DbbackupCommand()
        self.command.database = TEST_DATABASE['NAME']
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL

    def test_compress_file(self):
        inputfile = open(TEST_DATABASE['NAME'])
        self.command.compress_file(inputfile, 'foofile.txt')
class DbbackupCommandCompressFileTest(TestCase):
    def setUp(self):
        if six.PY3:
            self.skipTest("Compression isn't implemented in Python3")
        open(TEST_DATABASE['NAME'], 'a+b').close()
        self.command = DbbackupCommand()
        self.command.database = TEST_DATABASE['NAME']
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL

    def test_compress_file(self):
        inputfile = open(TEST_DATABASE['NAME'])
        self.command.compress_file(inputfile)
class DbbackupCommandSaveNewMongoBackupTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.encrypt = False
        self.command.compress = False
        self.command.dbcommands = MongoDBCommands(TEST_MONGODB)
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL

    def tearDown(self):
        clean_gpg_keys()

    def test_func(self, mock_run_commands):
        self.command.save_new_backup(TEST_DATABASE)
        self.assertTrue(mock_run_commands.called)
Exemple #6
0
class DbbackupCommandCleanupOldBackupsTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.database = TEST_DATABASE['NAME']
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.storage = FakeStorage()
        self.command.clean = True
        self.command.clean_keep = 1
        self.command.stdout = DEV_NULL

    def test_cleanup_old_backups(self):
        self.command.cleanup_old_backups(TEST_DATABASE)

    def test_cleanup_empty(self):
        self.command.storage.list_files = []
        self.command.cleanup_old_backups(TEST_DATABASE)
class DbbackupWriteLocallyTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.database = TEST_DATABASE["NAME"]
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL
        self.command.filename = None
        self.command.path = None

    def test_write(self):
        fd, path = six.BytesIO(b"foo"), "/tmp/foo.bak"
        self.command.write_local_file(fd, path)
        self.assertTrue(os.path.exists(path))
        # tearDown
        os.remove(path)
class DbbackupCommandSaveNewMongoBackupTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.encrypt = False
        self.command.compress = False
        self.command.dbcommands = MongoDBCommands(TEST_MONGODB)
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL

    def tearDown(self):
        clean_gpg_keys()

    def test_func(self, mock_run_commands):
        self.command._save_new_backup(TEST_DATABASE)
        self.assertTrue(mock_run_commands.called)
class DbbackupCommandCleanupOldBackupsTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.database = TEST_DATABASE['NAME']
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.storage = FakeStorage()
        self.command.clean = True
        self.command.clean_keep = 1
        self.command.stdout = DEV_NULL

    def test_cleanup_old_backups(self):
        self.command.cleanup_old_backups(TEST_DATABASE)

    def test_cleanup_empty(self):
        self.command.storage.list_files = []
        self.command.cleanup_old_backups(TEST_DATABASE)
class DbbackupWriteLocallyTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.database = TEST_DATABASE['NAME']
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL
        self.command.filename = None
        self.command.path = None
        self.command.connector = get_connector('default')

    def test_write(self):
        fd, path = six.BytesIO(b"foo"), '/tmp/foo.bak'
        self.command.write_local_file(fd, path)
        self.assertTrue(os.path.exists(path))
        # tearDown
        os.remove(path)
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.database = TEST_DATABASE['NAME']
     self.command.dbcommands = DBCommands(TEST_DATABASE)
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
     self.command.filename = None
     self.command.path = None
Exemple #12
0
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.encrypt = False
     self.command.compress = False
     self.command.dbcommands = MongoDBCommands(TEST_MONGODB)
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.database = TEST_DATABASE['NAME']
     self.command.dbcommands = DBCommands(TEST_DATABASE)
     self.command.storage = FakeStorage()
     self.command.clean = True
     self.command.clean_keep = 1
     self.command.stdout = DEV_NULL
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.database = TEST_DATABASE['NAME']
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
     self.command.filename = None
     self.command.path = None
     self.command.connector = get_connector('default')
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.database = TEST_DATABASE["NAME"]
     self.command.dbcommands = DBCommands(TEST_DATABASE)
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
     self.command.filename = None
     self.command.path = None
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.encrypt = False
     self.command.compress = False
     self.command.dbcommands = MongoDBCommands(TEST_MONGODB)
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
Exemple #17
0
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.database = TEST_DATABASE['NAME']
     self.command.dbcommands = DBCommands(TEST_DATABASE)
     self.command.storage = FakeStorage()
     self.command.clean = True
     self.command.clean_keep = 1
     self.command.stdout = DEV_NULL
class DbbackupCommandSaveNewMongoBackupTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.encrypt = False
        self.command.compress = False
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL
        self.command.filename = None
        self.command.path = None
        self.command.connector = get_connector('default')

    def tearDown(self):
        clean_gpg_keys()

    def test_func(self, mock_run_commands, mock_handle_size):
        self.command._save_new_backup(TEST_DATABASE)
        self.assertTrue(mock_run_commands.called)
 def setUp(self):
     if six.PY3:
         self.skipTest("Compression isn't implemented in Python3")
     open(TEST_DATABASE['NAME'], 'a+b').close()
     self.command = DbbackupCommand()
     self.command.database = TEST_DATABASE['NAME']
     self.command.dbcommands = DBCommands(TEST_DATABASE)
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
 def setUp(self):
     if six.PY3:
         self.skipTest("Compression isn't implemented in Python3")
     open(TEST_DATABASE['NAME'], 'a+b').close()
     self.command = DbbackupCommand()
     self.command.database = TEST_DATABASE['NAME']
     self.command.dbcommands = DBCommands(TEST_DATABASE)
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
class DbbackupCommandSaveNewMongoBackupTest(TestCase):
    def setUp(self):
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.encrypt = False
        self.command.compress = False
        self.command.storage = get_storage()
        self.command.stdout = DEV_NULL
        self.command.filename = None
        self.command.path = None
        self.command.connector = get_connector('default')

    def tearDown(self):
        clean_gpg_keys()

    def test_func(self, mock_run_commands, mock_handle_size):
        self.command._save_new_backup(TEST_DATABASE)
        self.assertTrue(mock_run_commands.called)
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.encrypt = False
     self.command.compress = False
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
     self.command.filename = None
     self.command.path = None
     self.command.connector = get_connector('default')
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.encrypt = False
     self.command.compress = False
     self.command.storage = get_storage()
     self.command.stdout = DEV_NULL
     self.command.filename = None
     self.command.path = None
     self.command.connector = get_connector('default')
 def setUp(self):
     open(TEST_DATABASE['NAME'], 'a+b').close()
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.encrypt = False
     self.command.compress = False
     self.command.database = TEST_DATABASE['NAME']
     self.command.dbcommands = DBCommands(TEST_DATABASE)
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
     open(TEST_DATABASE['NAME']).close()
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.encrypt = False
     self.command.compress = False
     self.command.database = TEST_DATABASE['NAME']
     self.command.storage = get_storage()
     self.command.connector = get_connector()
     self.command.stdout = DEV_NULL
     self.command.filename = None
     self.command.path = None
 def setUp(self):
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.encrypt = False
     self.command.compress = False
     self.command.database = TEST_DATABASE['NAME']
     self.command.storage = FakeStorage()
     self.command.connector = get_connector()
     self.command.stdout = DEV_NULL
     self.command.filename = None
     self.command.path = None
Exemple #27
0
 def setUp(self):
     open(TEST_DATABASE['NAME'], 'a+b').close()
     self.command = DbbackupCommand()
     self.command.servername = 'foo-server'
     self.command.encrypt = False
     self.command.compress = False
     self.command.database = TEST_DATABASE['NAME']
     self.command.dbcommands = DBCommands(TEST_DATABASE)
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
     open(TEST_DATABASE['NAME']).close()
Exemple #28
0
class DbbackupCommandSaveNewBackupTest(TestCase):
    def setUp(self):
        open(TEST_DATABASE['NAME'], 'a+b').close()
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.encrypt = False
        self.command.compress = False
        self.command.database = TEST_DATABASE['NAME']
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL
        open(TEST_DATABASE['NAME']).close()

    def tearDown(self):
        clean_gpg_keys()
        os.remove(TEST_DATABASE['NAME'])

    def test_func(self):
        self.command.save_new_backup(TEST_DATABASE)

    def test_compress(self):
        self.command.compress = True
        self.command.save_new_backup(TEST_DATABASE)

    def test_encrypt(self):
        add_public_gpg()
        self.command.encrypt = True
        self.command.save_new_backup(TEST_DATABASE)
Exemple #29
0
class DbbackupCommandSaveNewBackupTest(TestCase):
    def setUp(self):
        open(TEST_DATABASE['NAME'], 'a+b').close()
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.encrypt = False
        self.command.compress = False
        self.command.database = TEST_DATABASE['NAME']
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL
        open(TEST_DATABASE['NAME']).close()

    def tearDown(self):
        clean_gpg_keys()
        os.remove(TEST_DATABASE['NAME'])

    def test_func(self):
        self.command.save_new_backup(TEST_DATABASE)

    def test_compress(self):
        self.command.compress = True
        self.command.save_new_backup(TEST_DATABASE)

    def test_encrypt(self):
        add_public_gpg()
        self.command.encrypt = True
        self.command.save_new_backup(TEST_DATABASE)
class DbbackupCommandSaveNewBackupTest(TestCase):
    def setUp(self):
        open(TEST_DATABASE['NAME'], 'a+b').close()
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.encrypt = False
        self.command.compress = False
        self.command.database = TEST_DATABASE['NAME']
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL
        open(TEST_DATABASE['NAME']).close()

    def tearDown(self):
        try:
            cmd = ("gpg --batch --yes --delete-secret-key '%s'" % GPG_FINGERPRINT)
            subprocess.call(cmd, stdout=DEV_NULL, stderr=DEV_NULL)
        except OSError:
            pass
        os.remove(TEST_DATABASE['NAME'])

    def test_func(self):
        self.command.save_new_backup(TEST_DATABASE)

    def test_compress(self):
        self.command.compress = True
        self.command.save_new_backup(TEST_DATABASE)

    def test_encrypt(self):
        cmd = ('gpg --import %s' % GPG_PUBLIC_PATH).split()
        subprocess.call(cmd, stdout=DEV_NULL, stderr=DEV_NULL)
        self.command.encrypt = True
        self.command.save_new_backup(TEST_DATABASE)
class DbbackupCommandSaveNewBackupTest(TestCase):
    def setUp(self):
        if six.PY3:
            self.skipTest("Compression isn't implemented in Python3")
        open(TEST_DATABASE['NAME'], 'a+b').close()
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.encrypt = False
        self.command.compress = False
        self.command.database = TEST_DATABASE['NAME']
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL

    def test_func(self):
        self.command.save_new_backup(TEST_DATABASE)

    def test_compress(self):
        self.command.compress = True
        self.command.save_new_backup(TEST_DATABASE)

    def test_encrypt(self):
        cmd = ('gpg --import %s' % GPG_PUBLIC_PATH).split()
        subprocess.call(cmd, stdout=DEV_NULL, stderr=DEV_NULL)
        self.command.encrypt = True
        self.command.save_new_backup(TEST_DATABASE)
 def setUp(self):
     open(TEST_DATABASE["NAME"], "a+b").close()
     self.command = DbbackupCommand()
     self.command.servername = "foo-server"
     self.command.encrypt = False
     self.command.compress = False
     self.command.database = TEST_DATABASE["NAME"]
     self.command.dbcommands = DBCommands(TEST_DATABASE)
     self.command.storage = FakeStorage()
     self.command.stdout = DEV_NULL
     self.command.filename = None
     self.command.path = None
     open(TEST_DATABASE["NAME"]).close()
class DbbackupCommandSaveNewBackupTest(TestCase):
    def setUp(self):
        open(TEST_DATABASE["NAME"], "a+b").close()
        self.command = DbbackupCommand()
        self.command.servername = "foo-server"
        self.command.encrypt = False
        self.command.compress = False
        self.command.database = TEST_DATABASE["NAME"]
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL
        self.command.filename = None
        self.command.path = None
        open(TEST_DATABASE["NAME"]).close()

    def tearDown(self):
        clean_gpg_keys()
        os.remove(TEST_DATABASE["NAME"])

    def test_func(self):
        self.command._save_new_backup(TEST_DATABASE)

    def test_compress(self):
        self.command.compress = True
        self.command._save_new_backup(TEST_DATABASE)

    def test_encrypt(self):
        add_public_gpg()
        self.command.encrypt = True
        self.command._save_new_backup(TEST_DATABASE)

    def test_path(self):
        self.command.path = "/tmp/foo.bak"
        self.command._save_new_backup(TEST_DATABASE)
        self.assertTrue(os.path.exists(self.command.path))
        # tearDown
        os.remove(self.command.path)
class DbbackupCommandSaveNewBackupTest(TestCase):
    def setUp(self):
        if six.PY3:
            self.skipTest("Compression isn't implemented in Python3")
        open(TEST_DATABASE['NAME'], 'a+b').close()
        self.command = DbbackupCommand()
        self.command.servername = 'foo-server'
        self.command.encrypt = False
        self.command.compress = False
        self.command.database = TEST_DATABASE['NAME']
        self.command.dbcommands = DBCommands(TEST_DATABASE)
        self.command.storage = FakeStorage()
        self.command.stdout = DEV_NULL
        open(TEST_DATABASE['NAME']).close()

    def tearDown(self):
        try:
            cmd = ("gpg --batch --yes --delete-secret-key '%s'" %
                   GPG_FINGERPRINT)
            subprocess.call(cmd, stdout=DEV_NULL, stderr=DEV_NULL)
        except OSError:
            pass
        os.remove(TEST_DATABASE['NAME'])

    def test_func(self):
        self.command.save_new_backup(TEST_DATABASE)

    def test_compress(self):
        self.command.compress = True
        self.command.save_new_backup(TEST_DATABASE)

    def test_encrypt(self):
        cmd = ('gpg --import %s' % GPG_PUBLIC_PATH).split()
        subprocess.call(cmd, stdout=DEV_NULL, stderr=DEV_NULL)
        self.command.encrypt = True
        self.command.save_new_backup(TEST_DATABASE)