Skip to content

Commit

Permalink
adapt tests with changed http method: post
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-RLI committed Dec 16, 2024
1 parent 90e3af5 commit e3bde64
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions oekg/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ def setUp(self):
"sparql_endpoint"
) # Ensure your URL name matches the one in your urls.py

@patch("requests.get")
def test_valid_sparql_query(self, mock_get):
@patch("requests.post")
def test_valid_sparql_query(self, mock_post):
mock_response = Mock()
mock_response.status_code = 200
mock_response.json.return_value = {
"head": {"vars": ["sub", "pred", "obj"]},
"results": {"bindings": []},
}
mock_get.return_value = mock_response
mock_post.return_value = mock_response

query = """
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
Expand All @@ -31,21 +31,21 @@ def test_valid_sparql_query(self, mock_get):
LIMIT 10
"""

response = self.client.get(self.endpoint_url, {"query": query})
response = self.client.post(self.endpoint_url, {"query": query})
self.assertEqual(response.status_code, 200)
json_response = response.json()
self.assertIn("head", json_response)
self.assertIn("results", json_response)

@patch("requests.get")
def test_invalid_sparql_query_delete(self, mock_get):
@patch("requests.post")
def test_invalid_sparql_query_delete(self, mock_post):
query = """
DELETE WHERE {
?sub ?pred ?obj .
}
"""

response = self.client.get(self.endpoint_url, {"query": query})
response = self.client.post(self.endpoint_url, {"query": query})
self.assertEqual(
response.status_code, 400
) # Expecting 400 Bad Request for invalid queries
Expand Down

0 comments on commit e3bde64

Please sign in to comment.