Feature/new test#220
Merged
Merged
Conversation
2dd4242 to
a1c0922
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds and refactors taxonomy report-selection behavior while expanding model test coverage for taxonomy, email messages, and events.
Changes:
- Introduces
Taxonomy.get_matching_report(lang)and updates theget_matching_reporttemplate tag to delegate to it. - Expands taxonomy tests to cover report language matching and additional taxonomy validations.
- Extends EmailMessage tests with additional thread behavior checks and taxonomy/report fallback scenarios.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
ngen/models/taxonomy.py |
Adds get_matching_report(lang) helper on Taxonomy for report selection (self first, then ancestors). |
ngen/templatetags/ngen_tags.py |
Simplifies get_matching_report template tag to call the new model helper. |
ngen/tests/models/test_taxonomy.py |
Adds report-matching tests and extends taxonomy validation coverage. |
ngen/tests/models/test_email_message.py |
Improves queryset comparison and adds more EmailMessage + taxonomy/report fallback tests. |
ngen/tests/models/test_events.py |
Minor import-line change (type-ignore comment). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
71
to
+83
| def get_ancestors_reports(self, flat=True): | ||
| reports = self.get_ancestors_related(lambda obj: obj.reports.all()) | ||
| return [report for report_list in reports for report in report_list] | ||
| def get_matching_report(self, lang): | ||
| """ | ||
| Get the first report matching the given language for this taxonomy. | ||
| If no report is found for this taxonomy, it searches ancestor taxonomies. | ||
| """ | ||
| rep = self.reports.filter(lang=lang) | ||
| if rep.exists(): | ||
| return rep[:1] | ||
| else: | ||
| return [r for r in self.get_ancestors_reports() if r.lang == lang][:1] |
Comment on lines
+233
to
+247
| def test_alias_of_itself_raises_error(self): | ||
| """ | ||
| Test: Taxonomy cannot be an alias of itself. | ||
| """ | ||
| with self.assertRaises(ValidationError): | ||
| alias = Taxonomy(name="Invalid Alias", alias_of=self.parent) | ||
| alias.full_clean() | ||
|
|
||
| def test_alias_of_alias_raises_error(self): | ||
| """ | ||
| Test: Taxonomy cannot be an alias of another alias. | ||
| """ | ||
| with self.assertRaises(ValidationError): | ||
| alias = Taxonomy(name="Alias", alias_of=self.aNode_child3) | ||
| alias.full_clean() |
| import uuid | ||
|
|
||
| from django.test import TestCase | ||
| from django.test import TestCase # type: ignore |
Comment on lines
+59
to
+62
| cls.setUpReports() | ||
|
|
||
| @classmethod | ||
| def setUpReports(cls): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New tests for: