class_docstr: Tests saving/loading functionality of WithDBSettingsBase class.
class_docstr_tok: ["Tests","saving\/loading","functionality","of","WithDBSettingsBase","class","."]
code: def test_save_load_experiment_and_generation_strategy(self) -> None:
      (
          experiment,
          generation_strategy,
      ) = self.init_experiment_and_generation_strategy(
          save_generation_strategy=False
      )
      (
          db_exp,
          db_gs,
      ) = self.with_db_settings._load_experiment_and_generation_strategy(
          experiment.name
      )
      self.assertIsNotNone(db_exp)
      self.assertIsNone(db_gs)
  
      (
          experiment,
          generation_strategy,
      ) = self.init_experiment_and_generation_strategy(
          save_experiment=False, save_generation_strategy=False
      )
      (
          exp_saved,
          gs_saved,
      ) = self.with_db_settings._maybe_save_experiment_and_generation_strategy(
          experiment, generation_strategy
      )
      self.assertTrue(exp_saved)
      self.assertTrue(gs_saved)
  
      (
          db_exp,
          db_gs,
      ) = self.with_db_settings._load_experiment_and_generation_strategy(
          experiment.name
      )
      self.assertIsNotNone(db_exp)
      self.assertEqual(db_exp, experiment)
      self.assertIsNotNone(db_gs)
      self.assertEqual(db_gs.name, generation_strategy.name)
  
imports: import random
  import string
  from typing import Tuple
  from unittest.mock import patch
  from ax.core.base_trial import TrialStatus
  from ax.core.experiment import Experiment
  from ax.modelbridge.generation_strategy import GenerationStrategy
  from ax.service.utils.with_db_settings_base import WithDBSettingsBase
  from ax.storage.sqa_store.db import init_test_engine_and_session_factory
  from ax.storage.sqa_store.load import _load_experiment, _load_generation_strategy_by_experiment_name
  from ax.storage.sqa_store.reduced_state import GR_LARGE_MODEL_ATTRS
  from ax.storage.sqa_store.save import _save_experiment, _save_generation_strategy, _save_or_update_trials
  from ax.storage.sqa_store.structs import DBSettings
  from ax.utils.common.testutils import TestCase
  from ax.utils.testing.core_stubs import get_experiment, get_generator_run, SpecialGenerationStrategy
  from ax.utils.testing.modeling_stubs import get_generation_strategy
label_desc: Use image node_id 9 for calling the TestWithDBSettingsBase obj's underlying member method code with example usage: obj.test_save_load_experiment_and_generation_strategy() without return types