-
Notifications
You must be signed in to change notification settings - Fork 2
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
add MissingRequiredField error #59
base: main
Are you sure you want to change the base?
Conversation
harambe/errors.py
Outdated
@@ -12,6 +12,13 @@ def __init__(self, schema: Schema, data: ScrapeResult, message: str): | |||
super().__init__(f"Data {data} does not match schema {schema}. {message}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put the message first. It will often get lost in the sauce
test/parser/test_parser.py
Outdated
), | ||
], | ||
) | ||
def test_missing_required_field_error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an existing test_required_fields test. Can we append to the existing parameterized tests??
test/parser/test_parser.py
Outdated
{}, # ❌ Missing the required "name" field | ||
["name"], | ||
), | ||
# Test Case 2: Multiple required fields missing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These numberings aren't too helpful and annoying to manage as we move things around. Need to at least get rid of the number (I know we have a bunch of tests that have this, we should delete that junk)
test/parser/test_required_fields.py
Outdated
), | ||
], | ||
) | ||
def test_missing_required_field_error( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_pydantic_schema_validation_error_fail(
There is a already a failure case function at the top of the file. Let's append to that
harambe/__init__.py
Outdated
@@ -11,4 +17,8 @@ | |||
"AsyncScraperType", | |||
"AsyncScraper", | |||
"PAGE_PDF_FILENAME", | |||
"HarambeException", | |||
"SchemaValidationError", | |||
"MissingRequiredFieldError", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"MissingRequiredFieldError", | |
"MissingRequiredFieldsError", |
This should be plural. We will report all missing fields, not just one
test/parser/test_required_fields.py
Outdated
@pytest.mark.parametrize( | ||
"schema, data, missing_fields", | ||
[ | ||
( | ||
{ | ||
"name": { | ||
"type": "string", | ||
"required": True, | ||
"description": "The name of the person", | ||
} | ||
}, | ||
{}, # ❌ Missing the required "name" field | ||
["name"], | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole test function is a duplicate now
…_required_fields to handle nested lists properly
No description provided.