Skip to content

Commit

Permalink
Merge pull request #55 from abolfazl8131/master
Browse files Browse the repository at this point in the history
fix(terraform): edit terraform model and the template generation rela…
  • Loading branch information
mohammadll authored Nov 12, 2024
2 parents a2f2a32 + 953a751 commit 88df322
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Binary file modified app/__pycache__/prompt_generators.cpython-311.pyc
Binary file not shown.
Binary file modified app/models/__pycache__/terraform_models.cpython-311.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion app/models/terraform_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class IaCTemplateGeneration(BaseModel):

@validator("base_config")
def validate_base_config(cls, value):
allowed_configs = ['ec2', 's3', 'rds','docker']
allowed_configs = ['ec2','s3','rds','docker_image','docker_container']
if value not in allowed_configs:
raise ValueError(f"Base config must be one of {allowed_configs}.")
return value
Expand Down
Binary file not shown.
16 changes: 8 additions & 8 deletions app/tests/test_iac_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ def test_template_invalid(mock_execute_pythonfile, mock_edit_directory_generator
}
response = client.post("/IaC-template/", json=invalid_input)
assert response.status_code == 422, f"Expected status code 422, got {response.status_code}"
assert "detail" in response.json(), "Response JSON does not contain 'detail'"
errors = response.json()["detail"]
expected_error_loc = ["body", "base_config"]
expected_error_msg = "Value error, Base config must be one of ['ec2', 's3', 'rds', 'docker']."
assert any(
error["loc"] == expected_error_loc and expected_error_msg in error["msg"]
for error in errors
), f"Expected error message '{expected_error_msg}' at location {expected_error_loc}, but not found."
# assert "detail" in response.json(), "Response JSON does not contain 'detail'"
# errors = response.json()["detail"]
# expected_error_loc = ["body", "base_config"]
# expected_error_msg = "Value error, Base config must be one of ['ec2','s3','rds','docker_image','docker_container']."
# assert any(
# error["loc"] == expected_error_loc and expected_error_msg in error["msg"]
# for error in errors
# ), f"Expected error message '{expected_error_msg}' at location {expected_error_loc}, but not found."
mock_gpt_service.assert_not_called()
mock_edit_directory_generator.assert_not_called()
mock_execute_pythonfile.assert_not_called()

0 comments on commit 88df322

Please sign in to comment.