Skip to content
13 changes: 13 additions & 0 deletions tests/test_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -2743,6 +2743,19 @@ 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', 'correction', 'data-article', 'editorial',
'in-brief', 'letter', 'other', 'partial-retraction',
'rapid-communication', 'referee-report', 'reply',
'research-article', 'retraction', 'review-article',
]:
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
20 changes: 19 additions & 1 deletion xylose/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,25 @@
'ra': 'review-article',
'sc': 'rapid-communication',
'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',
'correction': 'correction',
'data-article': 'data-article',
'editorial': 'editorial',
'in-brief': 'in-brief',
'letter': 'letter',
'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',
}

periodicity = {
Expand Down