Skip to content

Commit db45848

Browse files
committed
ensure options are compared correctly (they were not being compared before)
1 parent a83f9a3 commit db45848

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

test/test_uri_spec.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
sys.path[0:0] = [""]
2424

25+
from pymongo.common import INTERNAL_URI_OPTION_NAME_MAP, validate
2526
from pymongo.uri_parser import parse_uri
2627
from test import clear_warning_registry, unittest
2728

@@ -114,14 +115,24 @@ def run_scenario(self):
114115
% (auth[elm], options[elm]))
115116

116117
# Compare URI options.
118+
err_msg = "For option %s expected %s but got %s"
117119
if test['options'] is not None:
120+
opts = options['options']
118121
for opt in test['options']:
119-
if options.get(opt) is not None:
122+
lopt = opt.lower()
123+
optname = INTERNAL_URI_OPTION_NAME_MAP.get(lopt, lopt)
124+
if opts.get(optname) is not None:
125+
if opts[optname] == test['options'][opt]:
126+
expected_value = test['options'][opt]
127+
else:
128+
expected_value = validate(
129+
lopt, test['options'][opt])[1]
120130
self.assertEqual(
121-
options[opt], test['options'][opt],
122-
"For option %s expected %s but got %s"
123-
% (opt, options[opt],
124-
test['options'][opt]))
131+
opts[optname], expected_value,
132+
err_msg % (opt, expected_value, opts[optname],))
133+
else:
134+
self.fail(
135+
"Missing expected option %s" % (opt,))
125136

126137
return run_scenario_in_dir(test_workdir)(run_scenario)
127138

test/uri_options/auth-options.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"authmechanism": "GSSAPI",
1212
"authMechanismProperties": {
1313
"SERVICE_NAME": "other",
14-
"CANONICALIZE_HOST_NAME": "true"
14+
"CANONICALIZE_HOST_NAME": true
1515
},
1616
"authSource": "$external"
1717
}

test/uri_options/connection-options.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"connectTimeoutMS": 20000,
1313
"heartbeatFrequencyMS": 5000,
1414
"localThresholdMS": 3000,
15-
"maxIdleTimeMS": 50000,
1615
"replicaSet": "uri-options-spec",
1716
"retryWrites": true,
1817
"serverSelectionTimeoutMS": 15000,

test/uri_options/read-preference-options.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"options": {
1111
"readPreference": "primaryPreferred",
1212
"readPreferenceTags": [
13-
"dc:ny,rack",
13+
"dc:ny,rack:1",
1414
"dc:ny"
1515
],
1616
"maxStalenessSeconds": 120

test/uri_options/tls-options.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"tls": true,
1212
"tlsCAFile": "ca.pem",
1313
"tlsCertificateKeyFile": "cert.pem",
14-
"tlsCertificateKeyPassword": "hunter2"
14+
"tlsCertificateKeyFilePassword": "hunter2"
1515
}
1616
},
1717
{

0 commit comments

Comments
 (0)