Repository: scieloorg/xylose

Issue:
Ajuste em metodo que indica modelo de dados HTML ou XML.

Discussion:

Patch:
diff --git a/setup.py b/setup.py
index d1e1950..03b10eb 100755
--- a/setup.py
+++ b/setup.py
@@ -7,7 +7,7 @@ except ImportError:
 
 setup(
     name="xylose",
-    version='0.43',
+    version='0.46',
     description="A SciELO library to abstract a JSON data structure that is a product of the ISIS2JSON conversion using the ISIS2JSON type 3 data model.",
     author="SciELO",
     author_email="scielo-dev@googlegroups.com",
diff --git a/xylose/scielodocument.py b/xylose/scielodocument.py
index 15d73da..a446175 100644
--- a/xylose/scielodocument.py
+++ b/xylose/scielodocument.py
@@ -802,9 +802,9 @@ class Article(object):
     def data_model_version(self, fullpath=False):
         """
         This method retrieves the document version
-        This method deals with the legacy fields (601).
+        This method deals with the legacy fields (120).
         """
-        if 'v601' in self.data['article']:
+        if 'xml' in self.data['article'].get('v120', [{'_': ''}])[0]['_'].lower():
             return 'xml'
 
         return 'html'


Test patch:
diff --git a/tests/test_document.py b/tests/test_document.py
index fa8d4c2..f9c49bf 100644
--- a/tests/test_document.py
+++ b/tests/test_document.py
@@ -985,6 +985,27 @@ class ArticleTests(unittest.TestCase):
 
         self.assertEqual(article.file_code(), '0034-8910-rsp-47-04-0675')
 
+    def test_data_model_version_html(self):
+        del(self.fulldoc['article']['v120'])
+
+        article = Article(self.fulldoc)
+
+        self.assertEqual(article.data_model_version, u'html')
+
+    def test_data_model_version_html_1(self):
+        self.fulldoc['article']['v120'] = [{'_': '4.0'}]
+
+        article = Article(self.fulldoc)
+
+        self.assertEqual(article.data_model_version, u'html')
+
+    def test_data_model_version_xml(self):
+        self.fulldoc['article']['v120'] = [{'_': 'XML_1.0'}]
+
+        article = Article(self.fulldoc)
+
+        self.assertEqual(article.data_model_version, u'xml')
+
     def test_wos_subject_areas(self):
         self.fulldoc['title']['v854'] = [{u'_': u'MARINE & FRESHWATER BIOLOGY'}, {u'_': u'OCEANOGRAPHY'}]