Ejemplo n.º 1
0
 def __init__(self, agent_datasource: AgentDatasource,
              config_storage: ConfigStorage,
              server_status_datasource: ServerStatusDatasource):
     self.server_status_datasource = server_status_datasource
     self.clai_commands: Dict[str, CommandRunner] = {
         "skills":
         ClaiPluginsCommandRunner(agent_datasource),
         "activate":
         ClaiSelectCommandRunner(config_storage, agent_datasource),
         "deactivate":
         ClaiUnselectCommandRunner(config_storage, agent_datasource),
         "manual":
         ClaiPowerDisableCommandRunner(server_status_datasource),
         "auto":
         ClaiPowerCommandRunner(server_status_datasource),
         "install":
         ClaiInstallCommandRunner(agent_datasource),
         "help":
         ClaiHelpCommandRunner()
     }
     self.clai_post_commands: Dict[str, PostCommandRunner] = {
         "activate": ClaiSelectCommandRunner(config_storage,
                                             agent_datasource),
         "install": ClaiInstallCommandRunner(agent_datasource)
     }
Ejemplo n.º 2
0
 def __init__(self, agent_datasource: AgentDatasource,
              config_storage: ConfigStorage,
              server_status_datasource: ServerStatusDatasource,
              orchestrator_provider: OrchestratorProvider):
     self.server_status_datasource = server_status_datasource
     self.clai_commands: Dict[str, CommandRunner] = {
         "skills":
         ClaiPluginsCommandRunner(agent_datasource),
         "orchestrate":
         ClaiOrchestrateCommandRunner(orchestrator_provider),
         "activate":
         ClaiSelectCommandRunner(config_storage, agent_datasource),
         "deactivate":
         ClaiUnselectCommandRunner(config_storage, agent_datasource),
         "manual":
         ClaiPowerDisableCommandRunner(server_status_datasource),
         "auto":
         ClaiPowerCommandRunner(server_status_datasource),
         "install":
         ClaiInstallCommandRunner(agent_datasource),
         "last-info":
         ClaiLastInfoCommandRunner(server_status_datasource),
         "reload":
         ClaiReloadCommandRunner(agent_datasource),
         "help":
         ClaiHelpCommandRunner()
     }
     self.clai_post_commands: Dict[str, PostCommandRunner] = {
         "activate": ClaiSelectCommandRunner(config_storage,
                                             agent_datasource),
         "last-info": ClaiLastInfoCommandRunner(server_status_datasource),
         "install": ClaiInstallCommandRunner(agent_datasource)
     }
Ejemplo n.º 3
0
def test_should_return_the_command_to_get_the_plugin_from_url_and_move_it_into_plugin_folder_server(
):
    agent_datasource = AgentDatasource()
    clai_install_command_runner = ClaiInstallCommandRunner(agent_datasource)
    command_to_execute = clai_install_command_runner.execute(
        CLAI_INSTALL_STATE_URL)
    dir_to_install = CLAI_INSTALL_STATE_URL.command.replace(
        f'{"clai install"}', '').strip()

    assert command_to_execute.suggested_command == f'cd $CLAI_PATH/clai/server/plugins && curl -O {dir_to_install}'
Ejemplo n.º 4
0
def test_should_return_the_command_to_get_the_plugin_from_route_and_move_it_into_plugin_folder_server(
        mocker):
    mock_exisit = mocker.patch('os.path.exists')
    mock_exisit.return_value = True
    mock_exisit = mocker.patch('os.path.isdir')
    mock_exisit.return_value = True
    agent_datasource = AgentDatasource()
    clai_install_command_runner = ClaiInstallCommandRunner(agent_datasource)
    command_to_execute = clai_install_command_runner.execute(
        CLAI_INSTALL_STATE_FOLDER)
    dir_to_install = CLAI_INSTALL_STATE_FOLDER.command.replace(
        f'{"clai install"}', '').strip()

    assert command_to_execute.suggested_command == f'cp -R {dir_to_install} $CLAI_PATH/clai/server/plugins'
Ejemplo n.º 5
0
def test_should_return_the_message_error_when_the_folder_doesnt_exist(mocker):
    mock_exisit = mocker.patch('os.path.exists')
    mock_exisit.return_value = False
    mock_exisit = mocker.patch('os.path.isdir')
    mock_exisit.return_value = False
    agent_datasource = AgentDatasource()
    clai_install_command_runner = ClaiInstallCommandRunner(agent_datasource)
    command_to_execute = clai_install_command_runner.execute(
        CLAI_INSTALL_STATE_FOLDER)
    dir_to_install = CLAI_INSTALL_STATE_FOLDER.command.replace(
        f'{"clai install"}', '').strip()

    assert command_to_execute.suggested_command == ':'
    assert command_to_execute.description == create_error_install(
        dir_to_install).description