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

add MissingRequiredField error #59

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

add MissingRequiredField error #59

wants to merge 10 commits into from

Conversation

seanmcguire12
Copy link

No description provided.

Copy link

linear bot commented Sep 11, 2024

@@ -12,6 +12,13 @@ def __init__(self, schema: Schema, data: ScrapeResult, message: str):
super().__init__(f"Data {data} does not match schema {schema}. {message}")
Copy link
Contributor

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

),
],
)
def test_missing_required_field_error(
Copy link
Contributor

@asim-shrestha asim-shrestha Sep 11, 2024

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??

{}, # ❌ Missing the required "name" field
["name"],
),
# Test Case 2: Multiple required fields missing
Copy link
Contributor

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)

),
],
)
def test_missing_required_field_error(
Copy link
Contributor

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

@@ -11,4 +17,8 @@
"AsyncScraperType",
"AsyncScraper",
"PAGE_PDF_FILENAME",
"HarambeException",
"SchemaValidationError",
"MissingRequiredFieldError",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"MissingRequiredFieldError",
"MissingRequiredFieldsError",

This should be plural. We will report all missing fields, not just one

Comment on lines 431 to 444
@pytest.mark.parametrize(
"schema, data, missing_fields",
[
(
{
"name": {
"type": "string",
"required": True,
"description": "The name of the person",
}
},
{}, # ❌ Missing the required "name" field
["name"],
),
Copy link
Contributor

@asim-shrestha asim-shrestha Sep 11, 2024

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

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.

2 participants