Skip to content

Commit

Permalink
test(main) remove unittest for prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
maralzar committed Nov 8, 2024
1 parent cf7d6e6 commit 81ffe5c
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 33 deletions.
10 changes: 1 addition & 9 deletions app/tests/test_iac_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,7 @@ def test_iac_basic_generation(mock_gpt_service, valid_iac_basic_data):
response = client.post("/IaC-basic/", json=valid_iac_basic_data.model_dump())
assert response.status_code == 200
assert response.json() == {"output": mocked_gpt_response}

expected_prompt = """
Write a robust answer about terraform, focusing on the latest update of terraform and based on this question:How do I manage state effectively in Terraform?,
minimun length of answer is 100 and maximum length is 500
"""
actual_prompt = " ".join(mock_gpt_service.call_args[0][0].split())
normalized_expected_prompt = " ".join(expected_prompt.split())
assert actual_prompt == normalized_expected_prompt


@patch('app.main.gpt_service')
def test_basic_generation(mock_gpt_service):
"""
Expand Down
13 changes: 0 additions & 13 deletions app/tests/test_iac_bugfix.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@ def test_bugfix(mock_gpt_service, valid_bugfix_data):
assert response.status_code == 200
assert response.json() == {"output": mocked_gpt_response}

expected_prompt = """
Write a clear answer to debug terraform
focusing on the version latest of terraform and based on this bug:Application fails to start on version latest,
generate a correct code that help us to solve this bug.
minimum length of answer is 100 and maximum length is 500
"""


actual_prompt = " ".join(mock_gpt_service.call_args[0][0].split())
normalized_expected_prompt = " ".join(expected_prompt.split())
assert actual_prompt == normalized_expected_prompt


@patch('app.main.gpt_service')
def test_bugfix_invalid(mock_gpt_service):
"""
Expand Down
11 changes: 0 additions & 11 deletions app/tests/test_iac_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,6 @@ def test_install(mock_gpt_service, valid_installation_data):
response = client.post("/IaC-install/", json=valid_installation_data.model_dump())
assert response.status_code == 200
assert response.json() == {"output": mocked_gpt_response}
expected_prompt = """
generate a clear shell script about installation terraform in ubuntu based on terraform document.
without any additional note. just script for installation. please consider new lines without any additional comment.
"""
actual_prompt = " ".join(mock_gpt_service.call_args[0][0].split()).strip()
normalized_expected_prompt = " ".join(expected_prompt.split()).strip()
if actual_prompt != normalized_expected_prompt:
print("Expected Prompt:", repr(normalized_expected_prompt))
print("Actual Prompt:", repr(actual_prompt))

assert actual_prompt == normalized_expected_prompt

@patch('app.main.gpt_service')
def test_install_invalid(mock_gpt_service):
Expand Down

0 comments on commit 81ffe5c

Please sign in to comment.