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

Refactor validate_query() #157

Merged
merged 4 commits into from
Oct 18, 2024
Merged

Conversation

marcocapozzoli
Copy link
Collaborator

Resolves #156

Copy link
Contributor

@andre-senna andre-senna left a comment

Choose a reason for hiding this comment

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

Please wait for @levisingularity and @eddiebrissow approvals before merging

@levisingularity levisingularity requested review from rafaellevidomuso and removed request for rafaellevidomuso October 17, 2024 13:53
@levisingularity levisingularity requested review from rafaellevidomuso and removed request for rafaellevidomuso October 17, 2024 13:56

return True
return True
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this should be outside the for.

Suggested change
return True
return True

@@ -33,12 +35,45 @@ def valid_event(self, action_type):
},
}
}

@pytest.fixture
def query_list(self, action_type):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Success are good an all for testing, but testing the invalid paths are very important as well.
If so, you would've caught the return True inside the for.

def validate_query(queries, *args, **kwargs) -> bool:
if isinstance(queries, dict):
queries = [queries]
elif not isinstance(queries, list) or not all(isinstance(query, dict) for query in queries):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This limits the query, such as [{}, []] or [[], []]. To ensure the parameters are correct, we can to perform a recursive check and run additional tests, or simply verify the top-level type as either a list or a dictionary.

Copy link
Contributor

Choose a reason for hiding this comment

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

simply verify the top-level type as either a list or a dictionary.

This sounds like a good plan for now. @angeloprobst , do you have any inputs here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that a recursive validation like the one suggested by @Pedrobc89 in the ticket covers all scenarios.

@marcocapozzoli marcocapozzoli merged commit 6c9895c into master Oct 18, 2024
5 checks passed
@marcocapozzoli marcocapozzoli deleted the imp/refactor-query-validator branch October 18, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants