Repository: scieloorg/xylose

Issue:
Adicionar o campo ``publisher_country`` a classe Journal
Para que possamos cadastrar o publisher_country no processamento inicial do Site, precisamos que esse atributo esteja no Xylose.

Discussion:

Patch:
diff --git a/xylose/scielodocument.py b/xylose/scielodocument.py
index 8f9703d..8676c4a 100644
--- a/xylose/scielodocument.py
+++ b/xylose/scielodocument.py
@@ -866,6 +866,24 @@ 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 copyright(self):
         """


Test patch:
diff --git a/tests/test_document.py b/tests/test_document.py
index 282c34f..30996d5 100644
--- a/tests/test_document.py
+++ b/tests/test_document.py
@@ -1085,6 +1085,26 @@ class JournalTests(unittest.TestCase):
 
         self.assertIsNone(journal.mission)
 
+    def test_journal_publisher_country(self):
+        journal = self.journal
+
+        expected = ('BR', 'Brazil')
+
+        self.assertEqual(journal.publisher_country, expected)
+
+    def test_journal_publisher_country_without_country(self):
+        journal = self.journal
+
+        del(journal.data['v310'])
+
+        self.assertIsNone(journal.publisher_country)
+
+    def test_journal_publisher_country_not_findable_code(self):
+        self.fulldoc['title']['v310'] = [{"_": "BRX"}]
+        journal = Journal(self.fulldoc['title'])
+
+        self.assertIsNone(journal.publisher_country)
+
 
     def test_journal_copyright(self):
         journal = self.journal