code: def test_cred1_call():
      keyring = MemoryKeyring()
      cred = UserPassword("name", keyring=keyring)
      # we will set the name but not the password, expecting UI
      # requesting it
      assert_equal(keyring.set("name", "user", "user1"), None)
      assert_equal(keyring.get("name", "user"), "user1")
      assert_equal(cred(), {"user": "user1", "password": "password1"})
      assert_equal(keyring.get("name", "password"), "password1")
      # without intervention the same credentials will be reused
      # in subsequent attempts
      assert_equal(cred(), {"user": "user1", "password": "password1"})
      with patch.dict(
          dlcfg._merged_store, {"datalad.credentials.force-ask": "yes"}
      ):
          assert_equal(
              cred(), {"user": "newuser", "password": "newpassword"}
          )
      assert_equal(keyring.get("name", "user"), "newuser")
      assert_equal(keyring.get("name", "password"), "newpassword")
  
file_path: datalad/datalad/downloaders/tests/test_credentials.py
imports: from unittest.mock import patch
  from datalad import cfg
  from datalad.api import Dataset
  from datalad.support.external_versions import external_versions
  from datalad.support.keyring_ import Keyring, MemoryKeyring
  from datalad.tests.utils_pytest import SkipTest, assert_equal, assert_false, assert_in, assert_raises, assert_true, ok_file_has_content, skip_if, with_tempfile, with_testsui
  from ..credentials import AWS_S3, CompositeCredential, GitCredential, UserPassword
label_desc: Use image node_id 2 for calling a global function with example usage: test_cred1_call() without return types