def runTest(self, current_user_mock, current_user, db_mock, popen_mock, get_server_details_mock): with self.app.app_context(): current_user.id = 1 current_user_mock.id = 1 current_app.PGADMIN_RUNTIME = False def db_session_add_mock(j): cmd_obj = loads(j.desc) self.assertTrue(isinstance(cmd_obj, IProcessDesc)) self.assertEqual(cmd_obj.backup_type, self.class_params['type']) self.assertEqual(cmd_obj.bfile, self.class_params['bfile']) self.assertEqual(cmd_obj.database, self.class_params['database']) self.assertEqual(cmd_obj.cmd, ' --file "backup_file" ' '--host "{0}" ' '--port "{1}" ' '--username "{2}" ' '--no-password ' '--database "{3}"'.format( self.class_params['host'], self.class_params['port'], self.class_params['username'], self.class_params['database'] )) db_mock.session.add.side_effect = db_session_add_mock db_mock.session.commit = MagicMock(return_value=True) get_server_details_mock.return_value = \ self.class_params['name'], \ self.class_params['host'], \ self.class_params['port'] backup_obj = BackupMessage( self.class_params['type'], self.class_params['sid'], self.class_params['bfile'], *self.class_params['args'], **{'database': self.class_params['database']} ) p = BatchProcess( desc=backup_obj, cmd=self.class_params['cmd'], args=self.class_params['args'] ) # Check that _create_process has been called self.assertTrue(db_mock.session.add.called) # Check start method self._check_start(popen_mock, p, backup_obj) # Check list method self._check_list(p, backup_obj)
def runTest(self, get_server_details_mock): get_server_details_mock.return_value = \ self.class_params['name'],\ self.class_params['host'],\ self.class_params['port'] backup_obj = BackupMessage( self.class_params['type'], self.class_params['sid'], self.class_params['bfile'], *self.class_params['args'], **{'database': self.class_params['database']}) # Check the expected message returned self.assertEqual(backup_obj.message, self.extected_msg) # Check the command obj_details = backup_obj.details(self.class_params['cmd'], self.class_params['args']) self.assertIn(self.expetced_details_cmd, obj_details)
def runTest(self, get_server_details_mock): get_server_details_mock.return_value = \ self.class_params['name'],\ self.class_params['host'],\ self.class_params['port'] backup_obj = BackupMessage( self.class_params['type'], self.class_params['sid'], self.class_params['bfile'], *self.class_params['args'], **{'database': self.class_params['database']} ) # Check the expected message returned self.assertEqual(backup_obj.message, self.extected_msg) # Check the command obj_details = backup_obj.details(self.class_params['cmd'], self.class_params['args']) self.assertIn(self.expetced_details_cmd, obj_details)
def runTest(self, get_server_name_mock, get_storage_directory_mock): get_server_name_mock.return_value = "{0} ({1}:{2})"\ .format( self.class_params['name'], self.class_params['host'], self.class_params['port']) backup_obj = BackupMessage( self.class_params['type'], self.class_params['sid'], self.class_params['bfile'], *self.class_params['args'], **{'database': self.class_params['database']}) get_storage_directory_mock.return_value = '/' # Check the expected message returned self.assertEqual(backup_obj.message, self.expected_msg) # Check the command obj_details = backup_obj.details(self.class_params['cmd'], self.class_params['args']) self.assertEqual(self.expected_details_cmd, obj_details['cmd'])