Skip to content

Feature/new test#220

Merged
mateodurante merged 5 commits into
developfrom
feature/new_test
Jun 23, 2026
Merged

Feature/new test#220
mateodurante merged 5 commits into
developfrom
feature/new_test

Conversation

@shereenTobia

Copy link
Copy Markdown

New tests for:

  • Email Message
  • Events
  • Taxonomy

mateodurante

This comment was marked as resolved.

mateodurante

This comment was marked as resolved.

@mateodurante mateodurante marked this pull request as ready for review June 23, 2026 16:00
Copilot AI review requested due to automatic review settings June 23, 2026 16:00
@mateodurante mateodurante dismissed their stale review June 23, 2026 16:02

changes applied

@mateodurante mateodurante merged commit 7bb7f9f into develop Jun 23, 2026
7 checks passed
@mateodurante mateodurante deleted the feature/new_test branch June 23, 2026 16:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 the get_matching_report template 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 thread ngen/models/taxonomy.py
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):
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.

4 participants