-
Notifications
You must be signed in to change notification settings - Fork 4
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 dossier to fragment #595
Conversation
Reviewer's Guide by SourceryThis pull request implements the "Add dossier to fragment" feature by adding dossiers to the fragment schema and domain models. Class diagram for new Dossier and Fragment relationshipclassDiagram
class Fragment {
+number: MuseumNumber
+dossiers: Sequence[str]
+other fields...
}
class DossierReference {
+dossierId: str
+isUncertain: bool
}
class DossierRecord {
+id: str
+description: Optional[str]
+is_approximate_date: bool
+year_range_from: Optional[int]
+year_range_to: Optional[int]
+related_kings: Sequence[float]
+provenance: Optional[Provenance]
+script: Optional[Script]
+references: Sequence[Reference]
}
Fragment "1" -- "*" DossierReference
DossierReference -- DossierRecord
note for Fragment "Fragment now includes dossier references"
note for DossierRecord "New entity to store dossier information"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @khoidt - I've reviewed your changes - here's some feedback:
Overall Comments:
- Changing order_global from int to float in the King class is a breaking change that could have unintended consequences. Please document the rationale for this change and ensure all consumers of this field are updated accordingly.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟡 Testing: 2 issues found
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
"dossiers": [ | ||
DossierReferenceSchema().dump(dossier) |
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.
suggestion (testing): Add a test case for empty dossiers list
It would be beneficial to include a test case where the dossiers
list is empty to ensure proper handling of this scenario.
Suggested implementation:
ScriptSchema,
DossierReferenceSchema,
)
from ebl.fragmentarium.application.joins_schema import JoinsSchema
from ebl.fragmentarium.domain.lemmatized_fragment import LemmatizedFragment
def test_serialize_lemmatized_fragment_empty_dossiers():
lemmatized_fragment = LemmatizedFragment(
# Add minimal required properties
number="X.1",
dossiers=[] # Empty dossiers list
)
serialized = LemmatizedFragmentSchema().dump(lemmatized_fragment)
assert serialized["dossiers"] == []
The test implementation assumes a basic LemmatizedFragment constructor. You may need to:
- Add any required constructor parameters based on your actual LemmatizedFragment class implementation
- Add any necessary test doubles/mocks for dependencies
- Adjust the assertion if there are additional properties that need to be verified
client, | ||
) -> None: |
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.
suggestion (testing): Test for invalid dossier IDs
Add a test case to verify the behavior of the API endpoint when provided with invalid or non-existent dossier IDs. This could involve checking for appropriate error responses (e.g., 404 Not Found) and ensuring that no unexpected exceptions are raised.
Suggested implementation:
assert sorted(get_result.json, key=lambda r: r["_id"]) == DossierRecordSchema(
many=True
).dump(sorted([dossier_record, another_dossier_record], key=lambda r: r.id))
def test_fetch_dossier_record_route_invalid_ids(
dossiers_repository: DossiersRepository,
client,
) -> None:
non_existent_id = "non_existent_id"
another_non_existent_id = "another_non_existent_id"
get_result = client.simulate_get(
"/dossiers",
params={"ids[]": [non_existent_id, another_non_existent_id]},
)
assert get_result.status == falcon.HTTP_NOT_FOUND
assert get_result.json == {
"title": "Dossiers not found",
"description": f"Dossiers with IDs {[non_existent_id, another_non_existent_id]} not found"
}
Note: This assumes that:
- The API endpoint is already set up to return a 404 status and appropriate error message when dossiers are not found
- If the error response format is different in the actual implementation, you'll need to adjust the assertion of get_result.json to match the actual error response structure
ids = parsed_params.get("ids[]", []) | ||
if not ids: | ||
raise ValueError("No valid IDs provided in the request.") |
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.
issue (code-quality): We've found these issues:
- Use named expression to simplify assignment and conditional (
use-named-expression
) - Lift code into else after jump in control flow (
reintroduce-else
) - Swap if/else branches (
swap-if-else-branches
)
Summary by Sourcery
New Features: