code: def test_cred1_enter_new():
      keyring = MemoryKeyring()
      cred = UserPassword("name", keyring=keyring)
      assert_false(cred.is_known)
      assert_equal(cred.enter_new(), None)
      assert_true(cred.is_known)
      assert_equal(keyring.get("name", "user"), "user1")
      assert_equal(keyring.get("name", "password"), "password1")
      keyring.delete("name")
      assert_raises(KeyError, keyring.delete, "name", "user")
      assert_raises(KeyError, keyring.delete, "name")
      assert_equal(keyring.get("name", "user"), None)
  
      # Test it blowing up if we provide unknown field
      with assert_raises(ValueError) as cme:
          cred.enter_new(username="user")
      assert_in(
          "field(s): username.  Known but not specified: password, user",
          str(cme.value),
      )
  
      # Test that if user is provided, it is not asked
      cred.enter_new(user="user2")
      assert_equal(keyring.get("name", "user"), "user2")
      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 1 for calling a global function with example usage: test_cred1_enter_new() without return types