code: def test_providers_enter_new(path=None):
      with patch.multiple(
          "platformdirs.AppDirs",
          site_config_dir=None,
          user_config_dir=path,
      ):
          providers_dir = op.join(path, "providers")
          providers = Providers.from_config_files(reload=True)
  
          url = "blah://thing"
          url_re = r"blah:\/\/.*"
          auth_type = "http_auth"
          creds = "user_password"
  
          @with_testsui(
              responses=["foo", url_re, auth_type, creds, "no"]
          )
          def no_save():
              providers.enter_new(url)
  
          no_save()
          assert_false(op.exists(op.join(providers_dir, "foo.cfg")))
  
          @with_testsui(
              responses=["foo", url_re, auth_type, creds, "yes"]
          )
          def save():
              providers.enter_new(url)
  
          save()
          ok_exists(op.join(providers_dir, "foo.cfg"))
  
          create_tree(path=providers_dir, tree={"exists.cfg": ""})
  
          @with_testsui(
              responses=[
                  "exists",
                  "foobert",
                  url_re,
                  auth_type,
                  creds,
                  "yes",
              ]
          )
          def already_exists():
              providers.enter_new(url)
  
          already_exists()
          ok_exists(op.join(providers_dir, "foobert.cfg"))
  
          @with_testsui(responses=["crawdad", "yes"])
          def known_provider():
              providers.enter_new(url)
  
          known_provider()
  
          @with_testsui(
              responses=["foo2", url_re, auth_type, creds, "yes"]
          )
          def auth_types():
              providers.enter_new(url, auth_types=["http_basic_auth"])
  
          auth_types()
          ok_exists(op.join(providers_dir, "foo2.cfg"))
  
          @with_testsui(
              responses=[
                  "foo3",
                  "doesn't match",
                  url_re,
                  auth_type,
                  creds,
                  "yes",
              ]
          )
          def nonmatching_url():
              providers.enter_new(url, auth_types=["http_basic_auth"])
  
          nonmatching_url()
          ok_exists(op.join(providers_dir, "foo3.cfg"))
  
file_path: datalad/datalad/downloaders/tests/test_providers.py
imports: import logging
  import os.path
  from unittest.mock import patch
  from ...support.external_versions import external_versions
  from ...tests.utils_pytest import assert_equal, assert_false, assert_greater, assert_in, assert_raises, ok_exists, swallow_logs, with_tempfile, with_testsui, with_tree
  from ...utils import chpwd, create_tree
  from ..providers import HTTPDownloader, Provider, Providers
label_desc: Use image node_id 6 for calling a global function with example usage: test_providers_enter_new(path) without return types