Permalink
Browse files

Ensure parse_uri accepts readPreference option

  • Loading branch information...
1 parent 24722fe commit ba89ff379d9ee9a4485059a29c12ec08e3aa7733 @craigahobbs craigahobbs committed Jan 23, 2013
Showing with 4 additions and 3 deletions.
  1. +2 −1 pymongo/common.py
  2. +2 −2 test/test_uri_parser.py
View
3 pymongo/common.py
@@ -162,6 +162,7 @@ def validate_tag_sets(dummy, value):
'connecttimeoutms': validate_timeout_or_none,
'sockettimeoutms': validate_timeout_or_none,
'ssl': validate_boolean,
+ 'readpreference': validate_read_preference,
'read_preference': validate_read_preference,
'tag_sets': validate_tag_sets,
'secondaryacceptablelatencyms': validate_positive_float,
@@ -258,7 +259,7 @@ def __set_options(self, options):
for option, value in options.iteritems():
if option in ('slave_okay', 'slaveok'):
self.__slave_okay = validate_boolean(option, value)
- elif option == 'read_preference':
+ elif option in ('read_preference', "readpreference"):
self.__read_pref = validate_read_preference(option, value)
elif option == 'tag_sets':
self.__tag_sets = validate_tag_sets(option, value)
View
4 test/test_uri_parser.py
@@ -270,9 +270,9 @@ def test_parse_uri(self):
"test.yield_historical.in?slaveok=true"))
res = copy.deepcopy(orig)
- res['options'] = {'read_preference': ReadPreference.SECONDARY}
+ res['options'] = {'readpreference': ReadPreference.SECONDARY}
self.assertEqual(res,
- parse_uri("mongodb://localhost/?read_preference=secondary"))
+ parse_uri("mongodb://localhost/?readPreference=secondary"))
if __name__ == "__main__":
unittest.main()

0 comments on commit ba89ff3

Please sign in to comment.