diff --git a/integraality/templates/queries.html b/integraality/templates/queries.html index 6347f75..651de55 100644 --- a/integraality/templates/queries.html +++ b/integraality/templates/queries.html @@ -1,16 +1,28 @@ {% extends "base.html" %} {% block content %}
From page {{ page_title }}, {{ column.format_html_snippet() | safe }}, {% if grouping == 'None' -%} without {{ formatted_predicate | safe }} grouping {%- elif grouping == 'UNKNOWN_VALUE' -%} with unknown value as {{ formatted_predicate | safe }} {%- elif grouping -%} with {{ grouping }} as {{ formatted_predicate | safe }} {%- else -%} for the totals {%- endif %}.
- All items with the {{ column.get_type_name() }} set - All items without the {{ column.get_type_name() }} set +Something went wrong when updating page {page}. Please check your configuration.
".format( page=self.linked_page ) # noqa self.assertErrorPage(response, message) def test_update_error_unknown_exception(self): self.mock_pages_processor.return_value.process_one_page.side_effect = ValueError response = self.app.get( "/update?page=%s&url=%s" % (self.page_title, self.page_url) ) self.mock_pages_processor.assert_called_once_with(self.page_url) self.mock_pages_processor.return_value.process_one_page.assert_called_once_with( page_title=self.page_title ) message = "Something catastrophic happened when processing page {page}.
".format( page=self.linked_page ) self.assertErrorPage(response, message) def test_update_error_query_exception(self): self.mock_pages_processor.return_value.process_one_page.side_effect = ( QueryException("Error", "SELECT X") ) response = self.app.get( "/update?page=%s&url=%s" % (self.page_title, self.page_url) ) self.mock_pages_processor.assert_called_once_with(self.page_url) self.mock_pages_processor.return_value.process_one_page.assert_called_once_with( page_title=self.page_title ) expected = ( 'Something went wrong when updating page Foo.
\n' "The following SPARQL query timed out or returned no result:
\n" "SELECT X\n"
)
self.assertErrorPage(response, expected)
buttons = (
'Try it in Wikidata Query Service'
'P495'
)
self.mock_grouping_configuration.property = "P495"
patcher1 = patch("pages_processor.PropertyStatistics", autospec=True)
self.mock_property_statistics = patcher1.start()
self.mock_property_statistics.grouping_configuration = (
self.mock_grouping_configuration
)
self.mock_property_statistics.columns = {
"P1": self.column_P1,
"Lbr": self.column_Lbr,
"Dbr": self.column_Dbr,
}
self.addCleanup(patcher1.stop)
def test_queries_success(self):
self.mock_pages_processor.return_value.make_stats_object_for_page_title.return_value = self.mock_property_statistics # noqa
self.mock_property_statistics.get_query_for_items_for_property_positive.return_value = "X"
self.mock_property_statistics.get_query_for_items_for_property_negative.return_value = "Z"
self.mock_property_statistics.GROUP_MAPPING.side_effect = ValueError
self.mock_property_statistics.GROUP_MAPPING.__members__.get.return_value = "Q2"
response = self.app.get(
"/queries?page=%s&url=%s&column=P1&grouping=Q2"
% (self.page_title, self.page_url)
)
self.mock_pages_processor.assert_called_once_with(self.page_url)
self.mock_pages_processor.return_value.make_stats_object_for_page_title.assert_called_once_with(
page_title=self.page_title
) # noqa
self.mock_property_statistics.get_query_for_items_for_property_positive.assert_called_once_with(
self.column_P1, "Q2"
)
self.mock_property_statistics.get_query_for_items_for_property_negative.assert_called_once_with(
self.column_P1, "Q2"
)
- expected = (
+ self.assertEqual(response.status_code, 200)
+ content = response.get_data(as_text=True)
+ expected_body = (
'\n\t'
- 'All items with the property set\n\t' # noqa
- 'All items without the property set' # noqa
)
- self.assertEqual(response.status_code, 200)
- self.assertPresent(expected, response.get_data(as_text=True))
+ self.assertPresent(expected_body, content)
+ expected_wdqs = (
+ 'WDQS: All items with the property set'
+ 'WDQS: All items without the property set'
+ )
+ self.assertPresent(expected_wdqs, content)
+ expected_qlever = (
+ 'From page Foo, '
'P1, '
'without P495 grouping.\n\t'
- 'All items with the property set\n\t' # noqa
- 'All items without the property set' # noqa
)
- self.assertEqual(response.status_code, 200)
- self.assertPresent(expected, response.get_data(as_text=True))
+ self.assertPresent(expected_body, content)
+ expected_wdqs = (
+ 'WDQS: All items with the property set'
+ 'WDQS: All items without the property set'
+ )
+ self.assertPresent(expected_wdqs, content)
+ expected_qlever = (
+ 'From page Foo, '
"br label, "
'with Q2 as P495.\n\t'
- 'All items with the label set\n\t' # noqa
- 'All items without the label set' # noqa
)
- self.assertEqual(response.status_code, 200)
- self.assertPresent(expected, response.get_data(as_text=True))
+ self.assertPresent(expected_body, content)
+ expected_wdqs = (
+ 'WDQS: All items with the label set'
+ 'WDQS: All items without the label set'
+ )
+ self.assertPresent(expected_wdqs, content)
+ expected_qlever = (
+ 'From page Foo, '
"br description, "
'with Q2 as P495.\n\t'
- 'All items with the description set\n\t' # noqa
- 'All items without the description set' # noqa
)
- self.assertEqual(response.status_code, 200)
- self.assertPresent(expected, response.get_data(as_text=True))
+ self.assertPresent(expected_body, content)
+ expected_wdqs = (
+ 'WDQS: All items with the description set'
+ 'WDQS: All items without the description set'
+ )
+ self.assertPresent(expected_wdqs, content)
+ expected_qlever = (
+ 'From page Foo, '
'P1, '
"for the totals.\n\t"
- 'All items with the property set\n\t' # noqa
- 'All items without the property set' # noqa
)
- self.assertEqual(response.status_code, 200)
- self.assertPresent(expected, response.get_data(as_text=True))
+ self.assertPresent(expected_body, content)
+ expected_wdqs = (
+ 'WDQS: All items with the property set'
+ 'WDQS: All items without the property set'
+ )
+ self.assertPresent(expected_wdqs, content)
+ expected_qlever = (
+ 'From page Foo, '
'P1, '
'with unknown value as P495.\n\t'
- 'All items with the property set\n\t' # noqa
- 'All items without the property set' # noqa
)
- self.assertEqual(response.status_code, 200)
- self.assertPresent(expected, response.get_data(as_text=True))
+ self.assertPresent(expected_body, content)
+ expected_wdqs = (
+ 'WDQS: All items with the property set'
+ 'WDQS: All items without the property set'
+ )
+ self.assertPresent(expected_wdqs, content)
+ expected_qlever = (
+ '