Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion solrorbit/utils/opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def convert(v):

result = {}
for kv in kvs:
k, v = kv.split(":")
k, v = kv.split(":", 1)
# key is always considered a string, value needs to be converted
result[k.strip()] = convert(v.strip())
return result
Expand Down
6 changes: 6 additions & 0 deletions tests/utils/opts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ def test_kv_to_map(self):
self.assertEqual({"k": "v", "size": 4, "empty": False, "temperature": 0.5},
opts.kv_to_map(["k:'v'", "size:4", "empty:false", "temperature:0.5"]))

def test_kv_to_map_value_contains_colon(self):
# only the first colon separates key and value; URLs, passwords and times keep theirs
self.assertEqual({"source": "http://mirror:8080/docs.json"}, opts.kv_to_map(["source:'http://mirror:8080/docs.json'"]))
self.assertEqual({"basic_auth_password": "s3:cr3t"}, opts.kv_to_map(["basic_auth_password:s3:cr3t"]))
self.assertEqual({"bulk_size": 100, "start": "12:30"}, opts.to_dict("bulk_size:100,start:'12:30'"))


class GenericHelperFunctionTests(TestCase):
def test_list_as_bulleted_list(self):
Expand Down
Loading