33import pytest
44import responses
55
6- from app import app , _cache , BASE_IRI , SPARQL_ENDPOINT
6+ from app import app , _cache , SPARQL_ENDPOINT
77
88
99SAMPLE_TURTLE = """\
@@ -100,9 +100,7 @@ def test_html_contains_clickable_links(client):
100100@responses .activate
101101def test_resolve_turtle_accept (client ):
102102 responses .get (SPARQL_ENDPOINT , body = SAMPLE_TURTLE , status = 200 )
103- resp = client .get (
104- "/Pathway/WP4846_r140186" , headers = {"Accept" : "text/turtle" }
105- )
103+ resp = client .get ("/Pathway/WP4846_r140186" , headers = {"Accept" : "text/turtle" })
106104 assert resp .status_code == 200
107105 assert "text/turtle" in resp .content_type
108106 assert b"wp:Pathway" in resp .data
@@ -130,7 +128,9 @@ def test_resolve_jsonld_extension(client):
130128
131129@responses .activate
132130def test_resolve_rdf_extension (client ):
133- rdfxml_body = '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"></rdf:RDF>'
131+ rdfxml_body = (
132+ '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"></rdf:RDF>'
133+ )
134134 responses .get (SPARQL_ENDPOINT , body = rdfxml_body , status = 200 )
135135 resp = client .get ("/Pathway/WP4846_r140186.rdf" )
136136 assert resp .status_code == 200
@@ -139,7 +139,7 @@ def test_resolve_rdf_extension(client):
139139
140140@responses .activate
141141def test_resolve_nt_extension (client ):
142- nt_body = ' <http://example.org/s> <http://example.org/p> <http://example.org/o> .\n '
142+ nt_body = " <http://example.org/s> <http://example.org/p> <http://example.org/o> .\n "
143143 responses .get (SPARQL_ENDPOINT , body = nt_body , status = 200 )
144144 resp = client .get ("/Pathway/WP4846_r140186.nt" )
145145 assert resp .status_code == 200
@@ -178,6 +178,7 @@ def test_empty_result_404_turtle(client):
178178@responses .activate
179179def test_sparql_connection_error_502 (client ):
180180 from requests .exceptions import ConnectionError as RequestsConnectionError
181+
181182 responses .get (SPARQL_ENDPOINT , body = RequestsConnectionError ("refused" ))
182183 resp = client .get ("/Pathway/WP4846_r140186" )
183184 assert resp .status_code == 502
@@ -186,6 +187,7 @@ def test_sparql_connection_error_502(client):
186187@responses .activate
187188def test_sparql_timeout_504 (client ):
188189 from requests .exceptions import ReadTimeout
190+
189191 responses .get (SPARQL_ENDPOINT , body = ReadTimeout ("timed out" ))
190192 resp = client .get ("/Pathway/WP4846_r140186" )
191193 assert resp .status_code == 504
@@ -234,9 +236,7 @@ def test_if_none_match_304(client):
234236 resp1 = client .get ("/Pathway/WP4846_r140186" )
235237 etag = resp1 .headers ["ETag" ]
236238 # Second request with If-None-Match
237- resp2 = client .get (
238- "/Pathway/WP4846_r140186" , headers = {"If-None-Match" : etag }
239- )
239+ resp2 = client .get ("/Pathway/WP4846_r140186" , headers = {"If-None-Match" : etag })
240240 assert resp2 .status_code == 304
241241
242242
@@ -271,6 +271,7 @@ def test_rate_limit_handler(client):
271271 """The 429 error handler returns a proper response."""
272272 with app .test_request_context ():
273273 from app import handle_429
274+
274275 resp = handle_429 (None )
275276 assert resp .status_code == 429
276277 assert b"Rate limit" in resp .data
0 commit comments