Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test cases for AAP-32080 #1327

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

TamiTakamiya
Copy link
Contributor

Jira Issue: https://issues.redhat.com/browse/AAP-32080

Description

Updates test cases based on the comments I got for #1326. Except for one line to add a log at DEBUG level, all changes are in test codes.

Testing

Steps to test

  1. Pull down the PR
  2. Run test cases

Scenarios tested

This is a PR on test cases.

Production deployment

  • This code change is ready for production on its own
  • This code change requires the following considerations before going to production:

@@ -474,6 +474,7 @@ def get_model_id(
organization_id: Optional[int] = None,
requested_model_id: str = "",
) -> str:
logger.debug(f"requested_model_id={requested_model_id}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new log line used only for testing.

@TamiTakamiya TamiTakamiya marked this pull request as ready for review September 27, 2024 19:58
@manstis
Copy link
Contributor

manstis commented Oct 9, 2024

Sorry @TamiTakamiya I finally got around to look at this and it now has a merge conflict.

lambda: None,
None,
)
self.assertInLog("requested_model_id=mymodel", log)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit overkill IMO since it doesn't really improve the quality of the code and it's testing a behaviour that is obvious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before AAP-32080, Explanations/Generation views did not specify requested_model_id when they call wca_client's get_model_id command. I agree it looks obvious, but this line ensures the requested_model_id is set as expected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @TamiTakamiya whilst the test may be an overkill it does detect and protect against a known issue.

However, I do struggle with these tests and the changes you made to support them. This class tests the view and it should be enough to ensure we call ModelMeshClient's method with the correct model_id. I'd then have tests for WCAClient that check the correct model_id is used e.g. https://github.com/ansible/ansible-ai-connect-service/blob/main/ansible_ai_connect/ai/api/model_client/tests/test_wca_client.py#L1259-L1264

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we've probably spent more time discussing these tests than they warrant.

I just think they smell weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@goneri What do you think? I am open to remove this line.

goneri
goneri previously approved these changes Oct 11, 2024
Copy link

sonarcloud bot commented Oct 14, 2024

@TamiTakamiya
Copy link
Contributor Author

@manstis @goneri I have resolved conflicts on test_views.py. Would you take a look at this again? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants