Repository: scieloorg/xylose

Issue:
[referências] Trocar o nome dos atributos analytic_authors e monographic_authors
- De analytic_authors para analytic_person_authors
- De monographic_authors para monographic_person_authors
Indicar obsolescência

```
    @property
    def analytic_authors(self):
        """
        This method retrieves the authors of the given citation. These authors
        may correspond to an article, book analytic, link or thesis.
        """

        authors = []
        if 'v10' in self.data:
            for author in self.data['v10']:
                authordict = {}
                if 's' in author:
                    authordict['surname'] = html_decode(author['s'])
                if 'n' in author:
                    authordict['given_names'] = html_decode(author['n'])
                if 's' in author or 'n' in author:
                    authors.append(authordict)

        if len(authors) > 0:
            return authors

    @property
    def monographic_authors(self):
        """
        This method retrieves the authors of the given book citation. These authors may
        correspond to a book monography citation.
        """

        authors = []
        if 'v16' in self.data:
            for author in self.data['v16']:
                authordict = {}
                if 's' in author:
                    authordict['surname'] = html_decode(author['s'])
                if 'n' in author:
                    authordict['given_names'] = html_decode(author['n'])
                if 's' in author or 'n' in author:
                    authors.append(authordict)

        if len(authors) > 0:
            return authors

```

Discussion:

Patch:
diff --git a/xylose/scielodocument.py b/xylose/scielodocument.py
index da4d426..f3559c9 100644
--- a/xylose/scielodocument.py
+++ b/xylose/scielodocument.py
@@ -1,7 +1,6 @@
 # encoding: utf-8
 import sys
 from functools import wraps
-import warnings
 import re
 import unicodedata
 import datetime
@@ -2826,80 +2825,33 @@ class Citation(object):
         if self.publication_type == 'article':
             return self.data.get('v35', None)
 
-    @property
-    def analytic_institution_authors(self):
-        """
-        It retrieves the analytic institution authors of a reference,
-        no matter the publication type of the reference.
-        It is not desirable to restrict the conditioned return to the
-        publication type, because some reference standards are very peculiar
-        and not only articles or books have institution authors.
-        IT REPLACES analytic_institution
-        """
-        institutions = []
-        for institution in self.data.get('v11', []):
-            institutions.append(html_decode(institution['_']))
-        if len(institutions) > 0:
-            return institutions
 
     @property
     def analytic_institution(self):
         """
         This method retrieves the institutions in the given citation. The
         citation must be an article or book citation, if it exists.
-        IT WILL BE DEPRECATED
         """
-        warn_future_deprecation(
-            'analytic_institution',
-            'analytic_institution_authors',
-            'analytic_institution_authors is more suitable name and '
-            'returns the authors independending on publication type'
-        )
         institutions = []
-        if self.publication_type in [u'article', u'book']:
+        if self.publication_type in [u'article', u'book'] and 'v11' in self.data:
             if 'v11' in self.data:
                 for institution in self.data['v11']:
-                    institutions.append(html_decode(institution['_']))
+                    institutions.append(html_decode(self.data['v11'][0]['_']))
 
         if len(institutions) > 0:
             return institutions
 
-    @property
-    def monographic_institution_authors(self):
-        """
-        It retrieves the monographic institution authors of a reference,
-        no matter the publication type of the reference.
-        It is not desirable to restrict the conditioned return to the
-        publication type, because some reference standards are very peculiar
-        and not only books have institution authors.
-        IT REPLACES monographic_institution
-        """
-        if 'v30' in self.data:
-            return
-        institutions = []
-        for institution in self.data.get('v17', []):
-            institutions.append(html_decode(institution['_']))
-        if len(institutions) > 0:
-            return institutions
-
     @property
     def monographic_institution(self):
         """
         This method retrieves the institutions in the given citation. The
         citation must be a book citation, if it exists.
-        IT WILL BE DEPRECATED
         """
-        warn_future_deprecation(
-            'monographic_institution',
-            'monographic_institution_authors',
-            'monographic_institution_authors is more suitable name and '
-            'returns the authors independending on publication type'
-        )
         institutions = []
         if self.publication_type == u'book' and 'v17' in self.data:
             if 'v17' in self.data:
                 for institution in self.data['v17']:
-                    institutions.append(html_decode(institution['_']))
+                    institutions.append(html_decode(self.data['v17'][0]['_']))
 
         if len(institutions) > 0:
             return institutions
@@ -3063,13 +3015,40 @@ class Citation(object):
         ma = self.monographic_authors or []
         return aa + ma
 
+    @property
+    def analytic_person_authors(self):
+        """
+        It retrieves the analytic person authors of a reference,
+        no matter the publication type of the reference.
+        It is not desirable to restrict the conditioned return to the
+        publication type, because some reference standards are very peculiar
+        and not only articles or books have person authors.
+        IT REPLACES analytic_authors
+        """
+        authors = []
+        for author in self.data.get('v10', []):
+            authordict = {}
+            if 's' in author:
+                authordict['surname'] = html_decode(author['s'])
+            if 'n' in author:
+                authordict['given_names'] = html_decode(author['n'])
+            if 's' in author or 'n' in author:
+                authors.append(authordict)
+        if len(authors) > 0:
+            return authors
+
     @property
     def analytic_authors(self):
         """
         This method retrieves the authors of the given citation. These authors
         may correspond to an article, book analytic, link or thesis.
+        IT WILL BE DEPRECATED. Use analytic_person_authors instead
         """
-
+        warn_future_deprecation(
+                'analytic_authors',
+                'analytic_person_authors',
+                'analytic_person_authors is more suitable name'
+        )
         authors = []
         if 'v10' in self.data:
             for author in self.data['v10']:
@@ -3084,13 +3063,41 @@ class Citation(object):
         if len(authors) > 0:
             return authors
 
+    @property
+    def monographic_person_authors(self):
+        """
+        It retrieves the monographic person authors of a reference,
+        no matter the publication type of the reference.
+        It is not desirable to restrict the conditioned return to the
+        publication type, because some reference standards are very peculiar
+        and not only articles or books have person authors.
+        IT REPLACES monographic_authors
+        """
+        authors = []
+        for author in self.data.get('v16', []):
+            authordict = {}
+            if 's' in author:
+                authordict['surname'] = html_decode(author['s'])
+            if 'n' in author:
+                authordict['given_names'] = html_decode(author['n'])
+            if 's' in author or 'n' in author:
+                authors.append(authordict)
+        if len(authors) > 0:
+            return authors
+
     @property
     def monographic_authors(self):
         """
-        This method retrieves the authors of the given book citation. These authors may
+        This method retrieves the authors of the given book citation.
+        These authors may
         correspond to a book monography citation.
+        IT WILL BE DEPRECATED. Use monographic_person_authors instead.
         """
-
+        warn_future_deprecation(
+                'monographic_authors',
+                'monographic_person_authors',
+                'monographic_person_authors is more suitable name'
+        )
         authors = []
         if 'v16' in self.data:
             for author in self.data['v16']:


Test patch:
diff --git a/tests/test_document.py b/tests/test_document.py
index b2b37dd..464098b 100644
--- a/tests/test_document.py
+++ b/tests/test_document.py
@@ -4136,106 +4136,20 @@ class CitationTest(unittest.TestCase):
         json_citation['v30'] = [{u'_': u'It is the journal title'}]
         json_citation['v12'] = [{u'_': u'It is the article title'}]
         json_citation['v11'] = [{u'_': u'Article Institution'}]
-        json_citation['v11'] = [
-            {u'_': u'Article Institution'},
-            {u'_': u'Article Institution 2'},
-        ]
 
         citation = Citation(json_citation)
-        self.assertEqual(
-            citation.analytic_institution,
-            [u'Article Institution', u'Article Institution 2']
-        )
+
+        self.assertEqual(citation.analytic_institution, [u'Article Institution'])
 
     def test_analytic_institution_for_a_book_citation(self):
         json_citation = {}
 
         json_citation['v18'] = [{u'_': u'It is the book title'}]
-        json_citation['v11'] = [
-            {u'_': u'Book Institution'},
-            {u'_': u'Book Institution 2'},
-        ]
-
-        citation = Citation(json_citation)
-
-        self.assertEqual(
-            citation.analytic_institution,
-            [u'Book Institution', u'Book Institution 2']
-        )
-
-    def test_pending_deprecation_warning_of_analytic_institution(self):
-        citation = Citation({})
-        with warnings.catch_warnings(record=True) as w:
-            items = citation.analytic_institution
-            assert items is None
-            assert len(w) == 1
-            assert issubclass(w[-1].category, PendingDeprecationWarning)
-
-    def test_pending_deprecation_warning_of_monographic_institution(self):
-        citation = Citation({})
-        with warnings.catch_warnings(record=True) as w:
-            items = citation.monographic_institution
-            assert items is None
-            assert len(w) == 1
-            assert issubclass(w[-1].category, PendingDeprecationWarning)
+        json_citation['v11'] = [{u'_': u'Book Institution'}]
 
-    def test_analytic_institution_authors_for_an_article_citation(self):
-        json_citation = {}
-
-        json_citation['v30'] = [{u'_': u'It is the journal title'}]
-        json_citation['v12'] = [{u'_': u'It is the article title'}]
-        json_citation['v11'] = [{u'_': u'Article Institution'}]
-        json_citation['v11'] = [
-            {u'_': u'Article Institution'},
-            {u'_': u'Article Institution 2'},
-        ]
         citation = Citation(json_citation)
-        self.assertEqual(
-            citation.analytic_institution_authors,
-            [u'Article Institution', u'Article Institution 2']
-        )
 
-    def test_analytic_institution_authors_for_a_book_citation(self):
-        json_citation = {}
-
-        json_citation['v18'] = [{u'_': u'It is the book title'}]
-        json_citation['v11'] = [
-            {u'_': u'Book Institution'},
-            {u'_': u'Book Institution 2'},
-        ]
-        citation = Citation(json_citation)
-        self.assertEqual(
-            citation.analytic_institution_authors,
-            [u'Book Institution', u'Book Institution 2']
-        )
-
-    def test_monographic_institution_authors_for_an_article_citation(self):
-        json_citation = {}
-
-        json_citation['v30'] = [{u'_': u'It is the journal title'}]
-        json_citation['v12'] = [{u'_': u'It is the article title'}]
-        json_citation['v17'] = [
-            {u'_': u'Article Institution'},
-            {u'_': u'Article Institution 2'},
-        ]
-        citation = Citation(json_citation)
-        self.assertEqual(
-            citation.monographic_institution_authors,
-            None
-        )
-
-    def test_monographic_institution_authors_for_a_book_citation(self):
-        json_citation = {}
-
-        json_citation['v18'] = [{u'_': u'It is the book title'}]
-        json_citation['v17'] = [
-            {u'_': u'Book Institution'},
-        ]
-        citation = Citation(json_citation)
-        self.assertEqual(
-            citation.monographic_institution_authors,
-            [u'Book Institution']
-        )
+        self.assertEqual(citation.analytic_institution, [u'Book Institution'])
 
     def test_thesis_institution(self):
         json_citation = {}
@@ -4386,6 +4300,112 @@ class CitationTest(unittest.TestCase):
 
         self.assertEqual(citation.authors, [])
 
+    def test_analytic_person_authors(self):
+        json_citation = {}
+
+        json_citation['v18'] = [{u'_': u'It is the book title'}]
+        json_citation['v12'] = [{u'_': u'It is the chapter title'}]
+        json_citation['v10'] = [{u's': u'Sullivan', u'n': u'Mike'},
+                                {u's': u'Hurricane Carter', u'n': u'Rubin'},
+                                {u's': u'Maguila Rodrigues', u'n': u'Adilson'},
+                                {u'n': u'Acelino Popó Freitas'},
+                                {u's': u'Zé Marreta'}]
+
+        expected = [{u'given_names': u'Mike', u'surname': u'Sullivan'},
+                    {u'given_names': u'Rubin', u'surname': u'Hurricane Carter'},
+                    {u'given_names': u'Adilson', u'surname': u'Maguila Rodrigues'},
+                    {u'given_names': u'Acelino Popó Freitas'},
+                    {u'surname': u'Zé Marreta'}]
+
+        citation = Citation(json_citation)
+
+        self.assertEqual(citation.analytic_person_authors, expected)
+
+    def test_without_analytic_person_authors(self):
+        json_citation = {}
+
+        json_citation['v18'] = [{u'_': u'It is the book title'}]
+        json_citation['v12'] = [{u'_': u'It is the chapter title'}]
+
+        citation = Citation(json_citation)
+
+        self.assertEqual(citation.analytic_person_authors, None)
+
+    def test_without_analytic_person_authors_but_not_a_book_citation(self):
+        json_citation = {}
+
+        json_citation['v30'] = [{u'_': u'It is the journal title'}]
+        json_citation['v12'] = [{u'_': u'It is the article title'}]
+        json_citation['v10'] = [{u's': u'Sullivan', u'n': u'Mike'},
+                                {u's': u'Hurricane Carter', u'n': u'Rubin'},
+                                {u's': u'Maguila Rodrigues', u'n': u'Adilson'},
+                                {u'n': u'Acelino Popó Freitas'},
+                                {u's': u'Zé Marreta'}]
+
+        expected = [{u'given_names': u'Mike', u'surname': u'Sullivan'},
+                    {u'given_names': u'Rubin', u'surname': u'Hurricane Carter'},
+                    {u'given_names': u'Adilson', u'surname': u'Maguila Rodrigues'},
+                    {u'given_names': u'Acelino Popó Freitas'},
+                    {u'surname': u'Zé Marreta'}]
+
+        citation = Citation(json_citation)
+
+        self.assertEqual(citation.analytic_person_authors, expected)
+
+    def test_monographic_person_authors(self):
+        json_citation = {}
+
+        json_citation['v18'] = [{u'_': u'It is the book title'}]
+        json_citation['v16'] = [{u's': u'Sullivan', u'n': u'Mike'},
+                                {u's': u'Hurricane Carter', u'n': u'Rubin'},
+                                {u's': u'Maguila Rodrigues', u'n': u'Adilson'},
+                                {u'n': u'Acelino Popó Freitas'},
+                                {u's': u'Zé Marreta'}]
+
+        expected = [{u'given_names': u'Mike', u'surname': u'Sullivan'},
+                    {u'given_names': u'Rubin', u'surname': u'Hurricane Carter'},
+                    {u'given_names': u'Adilson', u'surname': u'Maguila Rodrigues'},
+                    {u'given_names': u'Acelino Popó Freitas'},
+                    {u'surname': u'Zé Marreta'}]
+
+        citation = Citation(json_citation)
+
+        self.assertEqual(citation.monographic_person_authors, expected)
+
+    def test_without_monographic_person_authors(self):
+        json_citation = {}
+
+        json_citation['v18'] = [{u'_': u'It is the book title'}]
+        json_citation['v16'] = []
+
+        citation = Citation(json_citation)
+
+        self.assertEqual(citation.monographic_person_authors, None)
+
+    def test_without_monographic_person_authors_but_not_a_book_citation(self):
+        json_citation = {}
+
+        json_citation['v30'] = [{u'_': u'It is the journal title'}]
+        json_citation['v12'] = [{u'_': u'It is the article title'}]
+
+        citation = Citation(json_citation)
+
+        self.assertEqual(citation.monographic_person_authors, None)
+
+    def test_pending_deprecation_warning_of_analytic_authors(self):
+        citation = Citation({})
+        with warnings.catch_warnings(record=True) as w:
+            assert citation.analytic_authors is None
+            assert len(w) == 1
+            assert issubclass(w[-1].category, PendingDeprecationWarning)
+
+    def test_pending_deprecation_warning_of_monographic_authors(self):
+        citation = Citation({})
+        with warnings.catch_warnings(record=True) as w:
+            self.assertEqual(citation.monographic_authors, None)
+            assert len(w) == 1
+            assert issubclass(w[-1].category, PendingDeprecationWarning)
+
     def test_monographic_authors(self):
         json_citation = {}