Skip to content

Commit

Permalink
test: create test cases for description suggestion endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
citruscai committed Oct 10, 2024
1 parent b461129 commit b69568d
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,38 @@ def test_correct_spelling(text, expected):
response = app.test_client().post('/resume/spellcheck', json={'text': text})
assert response.status_code == 200
assert response.json['after'] == expected

# testcases for ai suggested imrpvoed descriptions
@patch('app.get_suggestion')
def test_get_description_suggestion(mock_get_suggestion):
'''
Test the /suggestion route with valid inputs
'''
mock_get_suggestion.return_value = "Improved description"

response = app.test_client().post('/suggestion', json={
'description': 'This is a sample description.',
'type': 'experience'
})

assert response.status_code == 200
assert response.json['suggestion'] == 'Improved description'


def test_get_description_suggestion_missing_fields():
'''
Test the /suggestion route with missing fields
'''
# Missing 'type'
response = app.test_client().post('/suggestion', json={
'description': 'This is a sample description.'
})
assert response.status_code == 400
assert response.json['error'] == 'Description and type are required'

# Missing 'description'
response = app.test_client().post('/suggestion', json={
'type': 'experience'
})
assert response.status_code == 400
assert response.json['error'] == 'Description and type are required'

0 comments on commit b69568d

Please sign in to comment.