Skip to content

Commit

Permalink
Fix linting issues.
Browse files Browse the repository at this point in the history
Add tests.
  • Loading branch information
yaph committed Jul 22, 2024
1 parent ade33e9 commit 485cf49
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions charla/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from charla import config

# UI text

t_open = 'OPEN: '
t_open_toolbar = 'Add to prompt: '
t_prompt = 'PROMPT: '
Expand Down Expand Up @@ -68,10 +69,9 @@ def get_content(source: str) -> str:
if source.startswith(('http://', 'https://')):
try:
resp = httpx.get(source, follow_redirects=True)
if 'text/html' == resp.headers['content-type']:
content = html2text(resp.text, baseurl=source)
else:
content = resp.text
content = html2text(
resp.text, baseurl=source
) if resp.headers['content-type'] == 'text/html' else resp.text
except httpx.ConnectError as err:
print(f'Enter an existing URL.\n{err}\n')
else:
Expand Down
12 changes: 8 additions & 4 deletions tests/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ def mock_args():
return p.parse_args([])


# def test_available_models():
# models = chat.available_models()
# assert len(models)
# assert 'name' in models[0]
def test_get_content_error():
assert '' == chat.get_content('https://does-not-exist')
assert '' == chat.get_content('does-not-exist.file')


def test_get_content_file():
content = chat.get_content('./tests/test_chat.py')
assert len(content)


def test_prompt_session():
Expand Down
3 changes: 0 additions & 3 deletions todo.md

This file was deleted.

0 comments on commit 485cf49

Please sign in to comment.