code: def test_ad_config_from_json():
      """Tests `from_json` method of `ADConfig`."""
      for param in [
          AD_CONFIG_JSON_DEFAULT,
          AD_CONFIG_JSON_PARTIAL,
          AD_CONFIG_JSON_COMPLETE,
      ]:
          ad_config = param.get("ad_config")
          ad_json = param.get("ad_json")
          translated_ad_config = ADConfig.from_json(ad_json)
          assert_equal_ad_config(ad_config, translated_ad_config)
  
      # Raises error when input is not a string
      with pytest.raises(ValueError, match="is not a json string."):
          ADConfig.from_json(5)
  
      # Raises error when input is not a json string
      with pytest.raises(ValueError, match="not a json string"):
          json_str = "This is not a json str"
          ADConfig.from_json(json_str)
  
file_path: greykite/greykite/tests/detection/detector/test_config.py
imports: import json
  import pytest
  from greykite.detection.detector.config import ADConfig
  from greykite.detection.detector.config import assert_equal_ad_config
  from greykite.detection.detector.config_utils import AD_CONFIG_JSON_COMPLETE
  from greykite.detection.detector.config_utils import AD_CONFIG_JSON_DEFAULT
  from greykite.detection.detector.config_utils import AD_CONFIG_JSON_PARTIAL
label_desc: Use image node_id 4 for calling a global function with example usage: test_ad_config_from_json() without return types