code: def test_invalid_database(monkeypatch, tmp_path, capsys):
      """Test if command prompt loops when invalid database is typed."""
      invalid_db_names = [
          "invalid database",
          "invalid database again",
          "2383ejdd",
          "another invalid database",
      ]
      config_path = str(tmp_path) + "/tmp_config.yaml"
      monkeypatch.setattr(
          orion.core, "DEF_CONFIG_FILES_PATHS", [config_path]
      )
      monkeypatch.setattr(
          builtins,
          "input",
          _mock_input(
              [
                  *invalid_db_names,
                  "mongodb",
                  "the host",
                  "the name",
              ]
          ),
      )
  
      orion.core.cli.main(["db", "setup"])
  
      with open(config_path) as output:
          content = yaml.safe_load(output)
  
      assert content == {
          "database": {
              "type": "mongodb",
              "name": "the name",
              "host": "the host",
          }
      }
  
      captured_output = capsys.readouterr().out
      for invalid_db_name in invalid_db_names:
          assert (
              "Unexpected value: {}. Must be one of: {}\n".format(
                  invalid_db_name,
                  ", ".join(
                      sorted(database_factory.get_classes().keys())
                  ),
              )
              in captured_output
          )
  
file_path: orion/tests/functional/commands/test_setup_command.py
imports: import builtins
  import os
  import yaml
  import orion.core
  import orion.core.cli
  from orion.core.io.database import database_factory
label_desc: Use image node_id 4 for calling a global function with example usage: test_invalid_database(monkeypatch, tmp_path, capsys) without return types