Skip to content

Commit bae5ea5

Browse files
DYung26christianchimezie
authored andcommitted
chore(tests): fix test directory references in workflow and resolve linting violations in test files
1 parent 3d5bbb8 commit bae5ea5

8 files changed

Lines changed: 382 additions & 284 deletions

File tree

.coverage

0 Bytes
Binary file not shown.

.github/workflows/python-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
env:
4444
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
4545
run: |
46-
uv run pytest test/ -v --cov=plotsense --cov-report=xml --cov-report=term-missing
46+
uv run pytest tests/ -v --cov=plotsense --cov-report=xml --cov-report=term-missing
4747
4848
- name: Upload coverage to Codecov
4949
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
@@ -77,7 +77,7 @@ jobs:
7777
7878
- name: Run unit tests only (fast)
7979
run: |
80-
uv run pytest test/ -v -m "not slow" --tb=short
80+
uv run pytest tests/ -v -m "not slow" --tb=short
8181
8282
lint:
8383
name: Code Quality
@@ -105,4 +105,4 @@ jobs:
105105
106106
- name: Check test code quality
107107
run: |
108-
uv run flake8 test --count --max-line-length=150 --statistics --extend-ignore=F401,F811
108+
uv run flake8 tests --count --max-line-length=150 --statistics --extend-ignore=F401,F811

plotsense/visual_suggestion/suggestions.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ class VisualizationRecommender:
2222
'groq': [
2323
('llama-3.3-70b-versatile', 0.5), # (model_name, weight)
2424
('llama-3.1-8b-instant', 0.5)
25-
2625
],
27-
2826
}
2927

3028
def __init__(self,

test_logs/pytest.log

Lines changed: 236 additions & 136 deletions
Large diffs are not rendered by default.

tests/unit/test_hidden_api_input.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,42 +7,42 @@
77

88
class TestHiddenAPIKeyInput:
99
"""Tests that API key input is hidden from terminal/logs."""
10-
10+
1111
def test_uses_getpass_not_input(self):
1212
"""Verify that getpass.getpass is used instead of input()."""
1313
with patch('getpass.getpass', return_value='hidden_key') as mock_getpass:
1414
key = prompt_for_api_key('groq', 'https://example.com', interactive=True)
15-
15+
1616
# Verify getpass was called
1717
mock_getpass.assert_called_once()
1818
assert key == 'hidden_key'
19-
19+
2020
def test_getpass_masks_input(self):
2121
"""Verify getpass hides input from terminal."""
2222
# getpass.getpass() does not echo input to terminal
2323
# This is verified by the fact that getpass module is imported
2424
# and used instead of builtins.input
2525
with patch('getpass.getpass', return_value='secret_api_key') as mock_getpass:
2626
key = prompt_for_api_key('openai', 'https://openai.com', interactive=True)
27-
27+
2828
# The getpass function is called with appropriate prompt
2929
call_args = mock_getpass.call_args[0][0]
3030
assert 'OPENAI' in call_args.upper()
3131
assert key == 'secret_api_key'
32-
32+
3333
def test_hidden_input_with_skip(self):
3434
"""Hidden input should work with skip_if_missing."""
3535
with patch('getpass.getpass', return_value='') as mock_getpass:
3636
key = prompt_for_api_key(
37-
'anthropic',
37+
'anthropic',
3838
'https://console.anthropic.com/keys',
3939
interactive=True,
4040
skip_if_missing=True
4141
)
42-
42+
4343
mock_getpass.assert_called_once()
4444
assert key is None
45-
45+
4646
def test_hidden_input_required_empty_raises(self):
4747
"""Empty hidden input should raise when key is required."""
4848
with patch('getpass.getpass', return_value='') as mock_getpass:
@@ -53,28 +53,28 @@ def test_hidden_input_required_empty_raises(self):
5353
interactive=True,
5454
skip_if_missing=False
5555
)
56-
56+
5757
mock_getpass.assert_called_once()
58-
58+
5959
def test_hidden_input_strips_whitespace(self):
6060
"""Hidden input should have whitespace stripped."""
61-
with patch('getpass.getpass', return_value=' api_key_with_spaces ') as mock_getpass:
61+
with patch('getpass.getpass', return_value=' api_key_with_spaces '):
6262
key = prompt_for_api_key('groq', 'https://console.groq.com/keys', interactive=True)
63-
63+
6464
# Whitespace should be stripped
6565
assert key == 'api_key_with_spaces'
6666
assert not key.startswith(' ')
6767
assert not key.endswith(' ')
68-
68+
6969
def test_hidden_input_non_interactive_no_getpass(self):
7070
"""Non-interactive mode should not call getpass."""
7171
with patch('getpass.getpass') as mock_getpass:
7272
with pytest.raises(ValueError):
7373
prompt_for_api_key('groq', 'https://console.groq.com/keys', interactive=False)
74-
74+
7575
# getpass should not be called in non-interactive mode
7676
mock_getpass.assert_not_called()
77-
77+
7878
def test_hidden_input_eof_error(self):
7979
"""Handle EOF when getpass is used."""
8080
with patch('getpass.getpass', side_effect=EOFError):
@@ -84,7 +84,7 @@ def test_hidden_input_eof_error(self):
8484
'https://aistudio.google.com/app/apikey',
8585
interactive=True
8686
)
87-
87+
8888
def test_hidden_input_os_error(self):
8989
"""Handle OSError when getpass is used."""
9090
with patch('getpass.getpass', side_effect=OSError):
@@ -94,23 +94,23 @@ def test_hidden_input_os_error(self):
9494
'https://portal.azure.com',
9595
interactive=True
9696
)
97-
97+
9898
def test_hidden_input_multiple_calls(self):
9999
"""Multiple hidden inputs should each use getpass."""
100100
with patch('getpass.getpass', side_effect=['key1', 'key2', 'key3']):
101101
key1 = prompt_for_api_key('groq', 'https://example.com', interactive=True)
102102
key2 = prompt_for_api_key('openai', 'https://example.com', interactive=True)
103103
key3 = prompt_for_api_key('anthropic', 'https://example.com', interactive=True)
104-
104+
105105
assert key1 == 'key1'
106106
assert key2 == 'key2'
107107
assert key3 == 'key3'
108-
108+
109109
def test_hidden_input_with_special_characters(self):
110110
"""Hidden input should handle special characters in API keys."""
111111
special_key = 'sk-key_with-special.chars+/=abc123'
112-
112+
113113
with patch('getpass.getpass', return_value=special_key):
114114
key = prompt_for_api_key('openai', 'https://platform.openai.com/api-keys', interactive=True)
115-
115+
116116
assert key == special_key

0 commit comments

Comments
 (0)