code: def test_tb_init_and_url_no_metadata_file(
      mock_metadata_file_present, mock_client
  ):
      """
      Test TensorBoardApp URL for the case when no metadata file is present.
      """
      mock_metadata_file_present.return_value = False
      mock_client.return_value = boto3.client("sagemaker")
      tb_app = TensorBoardApp(TEST_REGION)
      assert tb_app.region == TEST_REGION
      assert tb_app._domain_id is None
      assert tb_app._user_profile_name is None
      assert tb_app._in_studio_env is False
  
      # test url without job redirect
      assert tb_app.get_app_url(
          open_in_default_web_browser=False
      ) == BASE_URL_NON_STUDIO_FORMAT.format(region=TEST_REGION)
  
      # test url with valid job redirect
      assert tb_app.get_app_url(
          TEST_TRAINING_JOB, open_in_default_web_browser=False
      ) == BASE_URL_NON_STUDIO_FORMAT.format(
          region=TEST_REGION
      ) + REDIRECT_NON_STUDIO_FORMAT.format(
          TEST_TRAINING_JOB
      )
  
      # test url with invalid job redirect
      with pytest.raises(ValueError):
          tb_app.get_app_url("invald_job_name!")
  
      # test url when opened in web browser
      with patch("webbrowser.open") as mock_web_browser_open:
          url = tb_app.get_app_url(
              open_in_default_web_browser=True,
          )
          mock_web_browser_open.assert_called_with(
              BASE_URL_NON_STUDIO_FORMAT.format(region=TEST_REGION)
          )
          assert url == ""
  
imports: from __future__ import absolute_import
  import json
  from unittest.mock import patch, Mock, mock_open, PropertyMock
  import boto3
  import botocore
  import pytest
  from sagemaker.interactive_apps.tensorboard import TensorBoardApp
label_desc: Use image node_id 1 for calling a global function with example usage: test_tb_init_and_url_no_metadata_file(mock_metadata_file_present, mock_client) without return types