jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/463318 )
Change subject: [bugfix] partly revert [cleanup] tests/[script_tests.py-tests_tests.py] ......................................................................
[bugfix] partly revert [cleanup] tests/[script_tests.py-tests_tests.py]
partly revert of I97d24fa834e3f875a8547fc0e38f5a240f93907e
Bug: T205648 Change-Id: Id6ba0efc9195005d75c122d55923901e6772ffc7 --- M tests/sparql_tests.py 1 file changed, 45 insertions(+), 44 deletions(-)
Approvals: Dalba: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/sparql_tests.py b/tests/sparql_tests.py index ef9a0cb..7a84956 100644 --- a/tests/sparql_tests.py +++ b/tests/sparql_tests.py @@ -18,11 +18,11 @@
SQL_RESPONSE_CONTAINER = """ { - 'head' : { - 'vars' : [ 'cat', 'd', 'catLabel' ] + "head" : { + "vars" : [ "cat", "d", "catLabel" ] }, - 'results' : { - 'bindings' : [ + "results" : { + "bindings" : [ %s ] } @@ -31,19 +31,19 @@
ITEM_Q498787 = """ { - 'cat' : { - 'type' : 'uri', - 'value' : 'http://www.wikidata.org/entity/Q498787' + "cat" : { + "type" : "uri", + "value" : "http://www.wikidata.org/entity/Q498787" }, - 'd' : { - 'datatype' : 'http://www.w3.org/2001/XMLSchema#dateTime', - 'type' : 'literal', - 'value' : '1955-01-01T00:00:00Z' + "d" : { + "datatype" : "http://www.w3.org/2001/XMLSchema#dateTime", + "type" : "literal", + "value" : "1955-01-01T00:00:00Z" }, - 'catLabel' : { - 'xml:lang' : 'en', - 'type' : 'literal', - 'value' : 'Muezza' + "catLabel" : { + "xml:lang" : "en", + "type" : "literal", + "value" : "Muezza" } } """ @@ -51,33 +51,33 @@ ITEM_Q677525 = """ { "cat" : { - 'type' : 'uri', - 'value' : 'http://www.wikidata.org/entity/Q677525' + "type" : "uri", + "value" : "http://www.wikidata.org/entity/Q677525" }, - 'd' : { - 'datatype' : 'http://www.w3.org/2001/XMLSchema#dateTime', - 'type' : 'literal', - 'value' : '2015-06-22T00:00:00Z' + "d" : { + "datatype" : "http://www.w3.org/2001/XMLSchema#dateTime", + "type" : "literal", + "value" : "2015-06-22T00:00:00Z" }, - 'catLabel' : { - 'xml:lang' : 'en', - 'type' : 'literal', - 'value' : 'Orangey' + "catLabel" : { + "xml:lang" : "en", + "type" : "literal", + "value" : "Orangey" } } """
RESPONSE_TRUE = """ { - 'head' : { }, - 'boolean' : true + "head" : { }, + "boolean" : true } """
RESPONSE_FALSE = """ { - 'head' : { }, - 'boolean' : false + "head" : { }, + "boolean" : false } """
@@ -97,28 +97,30 @@ def testQuerySelect(self, mock_method): """Test SELECT query.""" mock_method.return_value = Container( - SQL_RESPONSE_CONTAINER % ('{}, {}' - .format(ITEM_Q498787, ITEM_Q677525))) + SQL_RESPONSE_CONTAINER % '{}, {}'.format( + ITEM_Q498787, ITEM_Q677525)) q = sparql.SparqlQuery() res = q.select('SELECT * WHERE { ?x ?y ?z }') self.assertIsInstance(res, list, 'Result is not a list') self.assertEqual(len(res), 2)
self.assertDictEqual( - res[0], {'cat': 'http://www.wikidata.org/entity/Q498787', - 'catLabel': 'Muezza', 'd': '1955-01-01T00:00:00Z'}, + res[0], + {'cat': 'http://www.wikidata.org/entity/Q498787', + 'catLabel': 'Muezza', 'd': '1955-01-01T00:00:00Z'}, 'Bad result') self.assertDictEqual( - res[1], {'cat': 'http://www.wikidata.org/entity/Q677525', - 'catLabel': 'Orangey', 'd': '2015-06-22T00:00:00Z'}, + res[1], + {'cat': 'http://www.wikidata.org/entity/Q677525', + 'catLabel': 'Orangey', 'd': '2015-06-22T00:00:00Z'}, 'Bad result')
@patch.object(sparql.http, 'fetch') def testQuerySelectFull(self, mock_method): """Test SELECT query with full data.""" mock_method.return_value = Container( - SQL_RESPONSE_CONTAINER % ('{}, {}' - .format(ITEM_Q498787, ITEM_Q677525))) + SQL_RESPONSE_CONTAINER % '{}, {}'.format( + ITEM_Q498787, ITEM_Q677525)) q = sparql.SparqlQuery() res = q.select('SELECT * WHERE { ?x ?y ?z }', full_data=True) self.assertIsInstance(res, list, 'Result is not a list') @@ -146,9 +148,8 @@ def testGetItems(self, mock_method): """Test item list retrieval via SPARQL.""" mock_method.return_value = Container( - SQL_RESPONSE_CONTAINER % ('{}, {}, {}'.format(ITEM_Q498787, - ITEM_Q677525, - ITEM_Q677525))) + SQL_RESPONSE_CONTAINER % '{}, {}, {}'.format( + ITEM_Q498787, ITEM_Q677525, ITEM_Q677525)) q = sparql.SparqlQuery() res = q.get_items('SELECT * WHERE { ?x ?y ?z }', 'cat') self.assertSetEqual(res, {'Q498787', 'Q677525'}) @@ -201,8 +202,8 @@ """Tests for sparql.Literal."""
net = False - object_under_test = sparql.Literal({'datatype': '', 'lang': 'en', - 'value': 'value'}) + object_under_test = sparql.Literal( + {'datatype': '', 'lang': 'en', 'value': 'value'})
class BnodeTests(Shared.SparqlNodeTests): @@ -216,8 +217,8 @@ """Tests for sparql.URI."""
net = False - object_under_test = sparql.URI({'value': 'http://foo.com%27%7D, - 'http://bar.com') + object_under_test = sparql.URI( + {'value': 'http://foo.com%27%7D, 'http://bar.com')
if __name__ == '__main__': # pragma: no cover
pywikibot-commits@lists.wikimedia.org