Skip to content
15 changes: 15 additions & 0 deletions tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -2743,6 +2743,21 @@ def test_invalid_document_type(self):
article.data['article']['v71'] = [{u'_': u'invalid'}]
self.assertEqual(article.document_type, u'undefined')

def test_document_type_from_article_type_attribute(self):

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

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

The test name mentions an "article_type attribute", but the test is setting the legacy field v71 directly. Renaming it to reflect what it actually validates (e.g., that document_type accepts JATS @article-type values stored in v71) would avoid confusion for future maintainers.

Suggested change
def test_document_type_from_article_type_attribute(self):
def test_document_type_accepts_jats_article_type_values_from_v71(self):

Copilot uses AI. Check for mistakes.
article = self.article

for article_type in [
'addendum', 'article-commentary', 'book-review', 'brief-report',
'case-report', 'clinical-instruction', 'correction',
'data-article', 'discussion', 'editorial',
'expression-of-concern', 'in-brief', 'letter', 'obituary',
'oration', 'other', 'partial-retraction', 'rapid-communication',
'referee-report', 'reply', 'research-article', 'retraction',
'review-article', 'reviewer-report',
]:
article.data['article']['v71'] = [{u'_': article_type}]
self.assertEqual(article.document_type, article_type)

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

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

This test only covers the new identity mappings (e.g. v71='retraction' -> 'retraction') but it doesn’t assert the corrected legacy-code mappings introduced in this PR (in/mt/sc/up). Add assertions for v71 values 'in', 'mt', 'sc', and 'up' mapping to 'other', 'review-article', 'brief-report', and 'rapid-communication' respectively, so the behavior change is protected by unit tests.

Suggested change
def test_document_type_from_legacy_v71_values(self):
article = self.article
legacy_mappings = {
u'in': u'other',
u'mt': u'review-article',
u'sc': u'brief-report',
u'up': u'rapid-communication',
}
for legacy_value, expected_type in legacy_mappings.items():
article.data['article']['v71'] = [{u'_': legacy_value}]
self.assertEqual(article.document_type, expected_type)

Copilot uses AI. Check for mistakes.
def test_without_original_title(self):
article = self.article

Expand Down
32 changes: 28 additions & 4 deletions xylose/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,43 @@
'ct': 'research-article',
'ed': 'editorial',
'er': 'correction',
'in': 'editorial',
'in': 'other',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot in é igual a interview e não other, mt é methodology.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 776740c: 'in': 'interview' and 'mt': 'methodology'.

'le': 'letter',
'mt': 'research-article',
'mt': 'review-article',
'nd': 'undefined',
'oa': 'research-article',
'pr': 'press-release',
'pv': 'editorial',
'rc': 'book-review',
'rn': 'brief-report',
'ra': 'review-article',
'sc': 'rapid-communication',
'sc': 'brief-report',
'tr': 'research-article',
'up': 'undefined'
'up': 'undefined',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot considere também esta tabela para conferir os valores
ab | abstracts
an | announcements
ax | annex
co | comments
cr | case report
ct | clinical trial
ed | editorial
er | correction
in | interview
le | letter
mt | methodology
oa | original article
pr | press release
pv | point-of-view
ra | review article
rc | recount
rn | research note
sc | brief communication
tr | technical report
up | update

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Cross-referenced the legacy codes table with the issue's @article-type mapping table and made the following corrections in fb7eda0:

Legacy code mapping fixes:

  • in (interview): editorialother
  • mt (methodology): research-articlereview-article
  • sc (brief communication): rapid-communicationbrief-report

Added missing @article-type identity mappings:

  • clinical-instruction, discussion, expression-of-concern, obituary, oration, reviewer-report

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot up = rapid-communication

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in f556ec4: 'up': 'rapid-communication'.

'addendum': 'addendum',
'article-commentary': 'article-commentary',
'book-review': 'book-review',
'brief-report': 'brief-report',
'case-report': 'case-report',
'clinical-instruction': 'clinical-instruction',
'correction': 'correction',
'data-article': 'data-article',
'discussion': 'discussion',
'editorial': 'editorial',
'expression-of-concern': 'expression-of-concern',
'in-brief': 'in-brief',
'letter': 'letter',
'obituary': 'obituary',
'oration': 'oration',
'other': 'other',
'partial-retraction': 'partial-retraction',
'rapid-communication': 'rapid-communication',
'referee-report': 'referee-report',
'reply': 'reply',
'research-article': 'research-article',
'retraction': 'retraction',
'review-article': 'review-article',
'reviewer-report': 'reviewer-report',
}

periodicity = {
Expand Down