Repository: scieloorg/xylose

Issue:
Adiciona o campo ``publisher_state`` a classe Journal 

Discussion:

Patch:
diff --git a/xylose/scielodocument.py b/xylose/scielodocument.py
index 0a6fdb0..b177a8d 100644
--- a/xylose/scielodocument.py
+++ b/xylose/scielodocument.py
@@ -567,18 +567,6 @@ class Journal(object):
             if len(langs) > 0:
                 return langs
 
-    @property
-    def abstract_languages(self):
-        """
-        This method retrieves a list of possible languages that the journal
-        publishes the abstracts.
-        This method deals with the legacy fields (v360).
-        """
-        if 'v360' in self.data:
-            langs = [i['_'] for i in self.data['v360'] if i['_'] in choices.ISO639_1_to_2.keys()]
-            if len(langs) > 0:
-                return langs
-
     @property
     def collection_acronym(self):
         """
@@ -717,20 +705,49 @@ class Journal(object):
         This method retrieves the publisher name of the given article,
         if it exists.
         This method deals with the legacy fields (480).
+
+        This method return a list:
+
+        ["Associa\u00e7\u00e3o Brasileira de Limnologia",
+        "Sociedade Botânica do Brasil"]
         """
+        if 'v480' not in self.data:
+            return None
 
-        return self.data.get('v480', [{'_': None}])[0]['_']
+        return [publisher['_'] for publisher in self.data.get('v480') if '_' in publisher and publisher['_'] != ""]
 
     @property
     def publisher_loc(self):
         """
-        This method retrieves the publisher localization of the given article,
+        This method retrieves the publisher localization of the given journal,
         if it exists.
         This method deals with the legacy fields (490).
         """
 
+        warnings.warn("deprecated, use journal.publisher_city", DeprecationWarning)
+
         return self.data.get('v490', [{'_': None}])[0]['_']
 
+    @property
+    def publisher_city(self):
+        """
+        This method retrieves the publisher localization of the given journal,
+        if it exists.
+        This method deals with the legacy fields (490).
+        """
+
+        return self.data.get('v490', [{'_': None}])[0]['_']
+
+    @property
+    def publisher_state(self):
+        """
+        This method retrieves the publisher state of the given journal,
+        if it exists.
+        This method deals with the legacy fields (320).
+        """
+
+        return self.data.get('v320', [{'_': None}])[0]['_']
+
     @property
     def title(self):
         """
@@ -741,6 +758,24 @@ class Journal(object):
 
         return self.data.get('v100', [{'_': None}])[0]['_']
 
+    @property
+    def publisher_country(self):
+        """
+        This method retrieves the publisher country of journal.
+        This method return a tuple: ('US', u'United States'), otherwise
+        return None.
+        """
+        if 'v310' not in self.data:
+            return None
+
+        country_code = self.data.get('v310', [{'_': None}])[0]['_']
+        country_name = choices.ISO_3166.get(country_code, None)
+
+        if not country_code or not country_name:
+            return None
+
+        return (country_code, country_name)
+
     @property
     def subtitle(self):
         """
@@ -927,24 +962,6 @@ class Journal(object):
 
         return missions
 
-    @property
-    def publisher_country(self):
-        """
-        This method retrieves the publisher country of journal.
-        This method return a tuple: ('US', u'United States'), otherwise
-        return None.
-        """
-        if 'v310' not in self.data:
-            return None
-
-        country_code = self.data.get('v310', [{'_': None}])[0]['_']
-        country_name = choices.ISO_3166.get(country_code, None)
-
-        if not country_code or not country_name:
-            return None
-
-        return (country_code, country_name)
-
     @property
     def copyrighter(self):
         """


Test patch:
diff --git a/tests/test_document.py b/tests/test_document.py
index 83a5588..e9cb6fb 100644
--- a/tests/test_document.py
+++ b/tests/test_document.py
@@ -435,18 +435,6 @@ class JournalTests(unittest.TestCase):
 
         self.assertEqual(journal.languages, None)
 
-    def test_abstract_languages(self):
-        journal = Journal(self.fulldoc['title'])
-
-        self.assertEqual(sorted(journal.abstract_languages), [u'en', u'pt'])
-
-    def test_abstract_languages_without_v350(self):
-        del(self.fulldoc['title']['v360'])
-
-        journal = Journal(self.fulldoc['title'])
-
-        self.assertEqual(journal.abstract_languages, None)
-
     def test_current_without_v51(self):
         del(self.fulldoc['title']['v51'])
 
@@ -1021,7 +1009,7 @@ class JournalTests(unittest.TestCase):
     def test_publisher_name(self):
         journal = self.journal
 
-        self.assertEqual(journal.publisher_name, u'Associação Brasileira de Limnologia')
+        self.assertEqual(journal.publisher_name, [u'Associação Brasileira de Limnologia'])
 
     def test_without_publisher_name(self):
         journal = self.journal
@@ -1040,6 +1028,28 @@ class JournalTests(unittest.TestCase):
         del(journal.data['v490'])
         self.assertEqual(journal.publisher_loc, None)
 
+    def test_publisher_city(self):
+        journal = self.journal
+
+        self.assertEqual(journal.publisher_city, u'Rio Claro')
+
+    def test_without_publisher_city(self):
+        journal = self.journal
+
+        del(journal.data['v490'])
+        self.assertEqual(journal.publisher_city, None)
+
+    def test_publisher_state(self):
+        journal = self.journal
+
+        self.assertEqual(journal.publisher_state, u'SP')
+
+    def test_without_publisher_state(self):
+        journal = self.journal
+
+        del(journal.data['v320'])
+        self.assertEqual(journal.publisher_state, None)
+
     def test_journal_title(self):
         journal = self.journal
 
@@ -1536,50 +1546,6 @@ class ArticleTests(unittest.TestCase):
 
         self.assertEqual(article.original_language(iso_format=None), u'en')
 
-    def test_publisher_name(self):
-        article = self.article
-
-        self.assertEqual(article.journal.publisher_name, u'Associação Brasileira de Limnologia')
-
-    def test_without_publisher_name(self):
-        article = self.article
-
-        del(article.data['title']['v480'])
-        self.assertEqual(article.journal.publisher_name, None)
-
-    def test_publisher_loc(self):
-        article = self.article
-
-        self.assertEqual(article.journal.publisher_loc, u'Rio Claro')
-
-    def test_without_publisher_loc(self):
-        article = self.article
-
-        del(article.data['title']['v490'])
-        self.assertEqual(article.journal.publisher_loc, None)
-
-    def test_journal_title(self):
-        article = self.article
-
-        self.assertEqual(article.journal.title, u'Acta Limnologica Brasiliensia')
-
-    def test_without_journal_title(self):
-        article = self.article
-
-        del(article.data['title']['v100'])
-        self.assertEqual(article.journal.title, None)
-
-    def test_journal_acronym(self):
-        article = self.article
-
-        self.assertEqual(article.journal.acronym, u'alb')
-
-    def test_without_journal_acronym(self):
-        article = self.article
-
-        del(article.data['title']['v68'])
-        self.assertEqual(article.journal.acronym, None)
-
     def test_publication_date(self):
         article = self.article
 
@@ -1620,7 +1586,6 @@ class ArticleTests(unittest.TestCase):
         article.data['article']['v93'] = [{u'_': u'20120419'}]
         self.assertEqual(article.creation_date, '2012-04-19')
 
-
     def test_creation_date_1(self):
         article = self.article
 
@@ -1769,7 +1734,6 @@ class ArticleTests(unittest.TestCase):
 
         self.assertEqual(article.elocation, None)
 
-
     def test_start_page_loaded_through_xml(self):
         article = self.article
 
@@ -1877,7 +1841,6 @@ class ArticleTests(unittest.TestCase):
 
         self.assertEqual(article.doi, u'10.1590/S2179-975X2012005000004')
 
-
     def test_doi_clean_1(self):
         article = self.article
 
@@ -1885,7 +1848,6 @@ class ArticleTests(unittest.TestCase):
 
         self.assertEqual(article.doi, u'10.1590/S2179-975X2012005000004')
 
-
     def test_doi_clean_2(self):
         article = self.article
 
@@ -2030,7 +1992,6 @@ class ArticleTests(unittest.TestCase):
 
         self.assertEqual(article.original_abstract(iso_format=None), None)
 
-
     def test_without_corporative_authors(self):
         article = self.article
 
@@ -2689,7 +2650,6 @@ class ArticleTests(unittest.TestCase):
 
         self.assertEqual(article.translated_titles(iso_format=None), expected)
 
-
     def test_translated_abstracts_without_v83(self):
         article = self.article