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

#124: Better error messages in case of missing parameters #148

Merged
merged 7 commits into from
Nov 2, 2023

Conversation

MarleneKress79789
Copy link
Collaborator

@MarleneKress79789 MarleneKress79789 commented Oct 27, 2023

All Submissions:

  • Is the title of the Pull Request correct?
  • Is the title of the corresponding issue correct?
  • Have you updated the changelog?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Are you mentioning the issue which this PullRequest fixes ("Fixes...")
  • Before you merge don't forget to run tests in AWS CodeBuild, by adding [CodeBuild] to the commit message
    Fixes Add better input validation for better error messages #124

Comment on lines 44 to 45
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ,"
"sub_dir, model_name", [
Copy link
Collaborator

@tkilias tkilias Oct 30, 2023

Choose a reason for hiding this comment

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

Suggested change
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ,"
"sub_dir, model_name", [
@pytest.mark.parametrize(["description", "bucketfs_conn_name", "bucketfs_conn" ,
"sub_dir", "model_name"], [

if parameter lists get long you can use either lists or sometimes you should also think about, if you create dataclass or so to wrap the parameters

Copy link
Collaborator

Choose a reason for hiding this comment

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

and another question is paramterize really necessary, because there is only one possible set

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is true but it makes it more consistent with the other test

Copy link
Collaborator

Choose a reason for hiding this comment

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

When I look at the tests, you probably, can also simplify them, because they share a lot of code, almost everything except input_data construction and asserts, so maybe extract that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

or alternatively, I sometimes have only one test and a parameter which specifies, if the test is expected to produce an error, and have two different asserts depending on that parameter

Comment on lines 44 to 45
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ,"
"sub_dir, model_name", [
Copy link
Collaborator

Choose a reason for hiding this comment

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

and another question is paramterize really necessary, because there is only one possible set

Comment on lines 84 to 85
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ,"
"sub_dir, model_name", [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ,"
"sub_dir, model_name", [
@pytest.mark.parametrize(["description", "bucketfs_conn_name", "bucketfs_conn" ,
"sub_dir", "model_name"], [

if parameter lists get long you can use either lists or sometimes you should also think about, if you create dataclass or so to wrap the parameters


@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ,"
"sub_dir, model_name", [
("all null", '', None, None, None),
Copy link
Collaborator

Choose a reason for hiding this comment

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

hm, it says all null, but bucketfs_Con is ''

tests/unit_tests/udfs/test_base_udf.py Outdated Show resolved Hide resolved
tests/unit_tests/udfs/test_base_udf.py Outdated Show resolved Hide resolved
MarleneKress79789 and others added 2 commits October 30, 2023 14:53
suggestions from code review

Co-authored-by: Torsten Kilias <[email protected]>
pattern = f"For each model model_name, bucketfs_conn and sub_dir need to be provided. Found model_name = " \
f"{model_name}, bucketfs_conn = .*, sub_dir = {sub_dir}."

assert re.search(pattern, error_field)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines 44 to 45
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ,"
"sub_dir, model_name", [
Copy link
Collaborator

Choose a reason for hiding this comment

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

When I look at the tests, you probably, can also simplify them, because they share a lot of code, almost everything except input_data construction and asserts, so maybe extract that.

Comment on lines 44 to 45
@pytest.mark.parametrize("description, bucketfs_conn_name, bucketfs_conn ,"
"sub_dir, model_name", [
Copy link
Collaborator

Choose a reason for hiding this comment

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

or alternatively, I sometimes have only one test and a parameter which specifies, if the test is expected to produce an error, and have two different asserts depending on that parameter

def __init__(self, some_sting):
self._string = some_sting

def __contains__(self, pattern):
Copy link
Collaborator

Choose a reason for hiding this comment

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

The eq in the linked example has a reason. This gives you a good diff. You used it then

assert actual_value == regex_matcher("abc.*")

@MarleneKress79789 MarleneKress79789 merged commit 5aacbce into main Nov 2, 2023
2 checks passed
@MarleneKress79789 MarleneKress79789 deleted the bug/#124_fix_input_validation branch November 2, 2023 11:07
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.

Add better input validation for better error messages
2 participants