Skip to content

Commit

Permalink
Merge pull request #826 from jfunez/820_adicionar_validate_style
Browse files Browse the repository at this point in the history
Adicionar `packtools.stylechecker.validate_style` e melhorar msgs no template #820
  • Loading branch information
gustavofonseca committed Jun 9, 2014
2 parents fc8c9aa + 8f9bbd4 commit 9419685
Show file tree
Hide file tree
Showing 5 changed files with 1,276 additions and 1,904 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ <h3>{% trans 'Notices' %}:</h3>
<li>
<a href="#annotations" data-toggle="tab">
{% trans "Style Checking" %}
{% if not xml_data.can_be_analyzed %}
{% if not xml_data.can_be_analyzed.0 %}
{# could not be analyzed #}
&nbsp;
<span class="badge badge-warning"></span>
Expand Down Expand Up @@ -201,10 +201,11 @@ <h3>{% trans 'Notices' %}:</h3>
</div>
<div class="tab-pane" id="annotations">
{# annotations #}
{% if not xml_data.can_be_analyzed %}
{% if not xml_data.can_be_analyzed.0 %}
{# could not be analyzed #}
<div class="alert alert-warning">
<i class="icon-minus-sign"></i> {% trans "The XML could not be analyzed" %}
<h4><i class="icon-minus-sign"></i> {% trans "The XML could not be analyzed" %}</h4>
<p>{{ xml_data.can_be_analyzed.1 }}</p>
</div>
{% elif not xml_data.annotations %}
{# xml without annotations #}
Expand Down
19 changes: 9 additions & 10 deletions scielomanager/articletrack/tests/tests_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def get_xml_uri(self, attempt_id, target_name):
xml_data = response.context['xml_data']

self.assertEqual(response.status_code, 200)
self.assertTrue(xml_data['can_be_analyzed'])
self.assertTrue(xml_data['can_be_analyzed'][0])
self.assertIsNone(xml_data['annotations'])
self.assertEqual(xml_data['uri'], expected_response['uri'])
self.assertIsNone(xml_data['validation_errors'])
Expand Down Expand Up @@ -294,7 +294,7 @@ def get_xml_uri(self, attempt_id, target_name):
xml_data = response.context['xml_data']

self.assertEqual(response.status_code, 200)
self.assertFalse(xml_data['can_be_analyzed'])
self.assertFalse(xml_data['can_be_analyzed'][0])
self.assertIsNone(xml_data['annotations'])
self.assertEqual(xml_data['uri'], expected_response['uri'])
self.assertIsNone(xml_data['validation_errors'])
Expand All @@ -305,7 +305,7 @@ def test_annotations_of_error(self):
notice = self._makeOne()

# MOCK/REPLACE/FAKE/PIMP MY BALAIO!!!
target_xml = "to_be_annotated.xml"
target_xml = "with_style_errors.xml"
expected_response = {
"filename": "1415-4757-gmb-37-0210.xml",
"uri": self._get_path_of_test_xml(target_xml)
Expand All @@ -324,19 +324,18 @@ def get_xml_uri(self, attempt_id, target_name):
reverse('notice_detail', args=[notice.checkin.pk]),
user=self.user)
xml_data = response.context['xml_data']

self.assertEqual(response.status_code, 200)
self.assertTrue(xml_data['can_be_analyzed'])
self.assertTrue(xml_data['can_be_analyzed'][0])
self.assertIsNotNone(xml_data['annotations'])
self.assertEqual(xml_data['uri'], expected_response['uri'])
self.assertEqual(xml_data['file_name'], expected_response['filename'])
self.assertIsNotNone(xml_data['validation_errors'])
self.assertEqual('7', xml_data['validation_errors']['error_lines'])
self.assertEqual('', xml_data['validation_errors']['error_lines'])
self.assertEqual(1, len(xml_data['validation_errors']['results']))
expected_validation_errors = {
'column': 0,
'line': 7,
'message': u"Element 'article-meta': This element is not expected. Expected is ( journal-meta ).",
'column': '--',
'line': '--',
'message': u"Element 'funding-group': This element is not filled-in correctly.",
'level': u'ERROR'
}
self.assertEqual([expected_validation_errors], xml_data['validation_errors']['results'])
Expand Down Expand Up @@ -368,7 +367,7 @@ def get_xml_uri(self, attempt_id, target_name):
xml_data = response.context['xml_data']

self.assertEqual(response.status_code, 200)
self.assertFalse(xml_data['can_be_analyzed'])
self.assertFalse(xml_data['can_be_analyzed'][0])
self.assertIsNone(xml_data['annotations'])
self.assertEqual(xml_data['uri'], expected_response['uri'])
self.assertEqual(xml_data['file_name'], expected_response['filename'])
Expand Down
Loading

0 comments on commit 9419685

Please sign in to comment.