Skip to content

Commit

Permalink
disable some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ricopinazo committed May 6, 2024
1 parent 1b58761 commit 37cacc7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/comai/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import List, Optional, Iterator
from typing_extensions import Annotated

from comai import config, __version__
from comai import __version__
from comai.chain import StreamStart, Token, FinalCommand, query_command
from comai.settings import load_settings
from comai.context import get_context
Expand Down
55 changes: 29 additions & 26 deletions tests/test_comai.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
import os
from typer.testing import CliRunner
from dotenv import load_dotenv
from comai import cli, config, translation, context, __version__
from comai.history import History

load_dotenv()
# from dotenv import load_dotenv
from comai import cli, context, __version__

# from comai.history import History

# load_dotenv()
api_key = os.getenv("OPENAI_API_KEY")

runner = CliRunner()


def test_invalid_api_key():
config.delete_api_key()
# def test_invalid_api_key():
# config.delete_api_key()

result = runner.invoke(cli.app, ["show", "files"], input="bad-api-key\n")
assert result.exit_code != 0
assert "API key not valid" in result.stdout
# result = runner.invoke(cli.app, ["show", "files"], input="bad-api-key\n")
# assert result.exit_code != 0
# assert "API key not valid" in result.stdout


def test_installation_flow():
config.delete_api_key()
# def test_installation_flow():
# config.delete_api_key()

result = runner.invoke(cli.app, ["show", "files"], input=f"{api_key}\n\n")
assert result.exit_code == 0
assert "Please enter your OpenAI API key:" in result.stdout
assert "ls" in result.stdout
# result = runner.invoke(cli.app, ["show", "files"], input=f"{api_key}\n\n")
# assert result.exit_code == 0
# assert "Please enter your OpenAI API key:" in result.stdout
# assert "ls" in result.stdout

result = runner.invoke(cli.app, ["show", "files"], input="\n")
assert result.exit_code == 0
assert "Please enter your OpenAI API key:" not in result.stdout
assert "ls" in result.stdout
# result = runner.invoke(cli.app, ["show", "files"], input="\n")
# assert result.exit_code == 0
# assert "Please enter your OpenAI API key:" not in result.stdout
# assert "ls" in result.stdout


def test_version():
Expand All @@ -43,11 +45,12 @@ def test_missing_instruction():
assert result.exit_code != 0


def test_translation():
ctx = context.get_context()
history = History.create_local()
history.append_user_message("show files")
# TODO: create a mock ollama server that always returns "COMMAND ls END"
# def test_translation():
# ctx = context.get_context()
# history = History.create_local()
# history.append_user_message("show files")

answer = translation.request_command(history, ctx, api_key)
command = translation.filter_assistant_message(answer)
assert "".join(command) == "ls"
# answer = translation.request_command(history, ctx, api_key)
# command = translation.filter_assistant_message(answer)
# assert "".join(command) == "ls"

0 comments on commit 37cacc7

Please sign in to comment.