Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make bool values lowercase in solr query url - fixes #401 #435

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix style errors
  • Loading branch information
ch2ohch2oh committed Oct 14, 2023
commit 5876d4b5747e0c1454276b24c63925b53bb8bf47
6 changes: 2 additions & 4 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import random
import time
import unittest
import json
from io import StringIO
from xml.etree import ElementTree

Expand All @@ -18,11 +17,10 @@
clean_xml_string,
force_bytes,
force_unicode,
json,
get_nested,
safe_urlencode,
sanitize,
unescape_html,
get_nested,
)

try:
Expand Down Expand Up @@ -75,7 +73,7 @@
)

# Boolean options for Solr should be in lowercase.
self.assertTrue("True" not in safe_urlencode(dict(group=True)))
self.assertTrue("True" not in safe_urlencode({"group": True}))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would pass a bug which encoded it as group=None or group="false".

Suggested change
self.assertTrue("True" not in safe_urlencode({"group": True}))
self.assertEqual("group=true", safe_urlencode({"group": True}))


def test_sanitize(self):
self.assertEqual(
Expand Down Expand Up @@ -276,8 +274,8 @@

def test_init(self):
self.assertEqual(self.solr.url, "http:https://localhost:8983/solr/core0")
self.assertIsInstance(self.solr.decoder, json.JSONDecoder)

Check failure on line 277 in tests/test_client.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

tests/test_client.py:277:50: F821 Undefined name `json`
self.assertIsInstance(self.solr.encoder, json.JSONEncoder)

Check failure on line 278 in tests/test_client.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

tests/test_client.py:278:50: F821 Undefined name `json`
self.assertEqual(self.solr.timeout, 60)

custom_solr = self.get_solr("core0", timeout=17, always_commit=True)
Expand Down Expand Up @@ -360,12 +358,12 @@
def test__select(self):
# Short params.
resp_body = self.solr._select({"q": "doc"})
resp_data = json.loads(resp_body)

Check failure on line 361 in tests/test_client.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

tests/test_client.py:361:21: F821 Undefined name `json`
self.assertEqual(resp_data["response"]["numFound"], 3)

# Long params.
resp_body = self.solr._select({"q": "doc" * 1024})
resp_data = json.loads(resp_body)

Check failure on line 366 in tests/test_client.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

tests/test_client.py:366:21: F821 Undefined name `json`
self.assertEqual(resp_data["response"]["numFound"], 0)
self.assertEqual(len(resp_data["responseHeader"]["params"]["q"]), 3 * 1024)

Expand All @@ -373,7 +371,7 @@
resp_body = self.solr._select(
{"q": "*", "cursorMark": "*", "sort": "id desc", "start": 0, "rows": 2}
)
resp_data = json.loads(resp_body)

Check failure on line 374 in tests/test_client.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

tests/test_client.py:374:21: F821 Undefined name `json`
self.assertEqual(len(resp_data["response"]["docs"]), 2)
self.assertIn("nextCursorMark", resp_data)

Expand All @@ -384,12 +382,12 @@

def test__mlt(self):
resp_body = self.solr._mlt({"q": "id:doc_1", "mlt.fl": "title"})
resp_data = json.loads(resp_body)

Check failure on line 385 in tests/test_client.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

tests/test_client.py:385:21: F821 Undefined name `json`
self.assertEqual(resp_data["response"]["numFound"], 0)

def test__suggest_terms(self):
resp_body = self.solr._select({"terms.fl": "title"})
resp_data = json.loads(resp_body)

Check failure on line 390 in tests/test_client.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

tests/test_client.py:390:21: F821 Undefined name `json`
self.assertEqual(resp_data["response"]["numFound"], 0)

def test__update(self):
Expand All @@ -414,7 +412,7 @@
self.headers = {}

def json(self):
return json.loads(self.content)

Check failure on line 415 in tests/test_client.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F821)

tests/test_client.py:415:24: F821 Undefined name `json`

# Just the reason.
resp_1 = RubbishResponse("We don't care.", {"reason": "Something went wrong."})
Expand Down
Loading